Click here to watch on Youtube:
https://www.youtube.com/watch?v=MM8E530p-9g&list=UUhwKlOVR041tngjerWxVccw
CalendarDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/CalendarDemo_equals.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/CalendarDemo_equals
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/b1e669f4abac38a0eb65bfeb213dca88c58230cc/BasicJava_2018/CalendarDemo_equals/?at=master
See also:
All JavaEE Videos Playlist
All JavaEE Videos
All JAVA EE Links
Spring Tutorial
Servlets Tutorial
All Design Patterns Links
JDBC Tutorial
Java Collection Framework Tutorial
JAVA Tutorial
Kids Tutorial
Cooking Tutorial
https://www.youtube.com/watch?v=MM8E530p-9g&list=UUhwKlOVR041tngjerWxVccw
CalendarDemo.java
import java.util.Calendar;
public class CalendarDemo
{
public static void main(String[] args)
{
Calendar cal1 = Calendar.getInstance();
System.out.println("Current date = " + cal1.getTime());
Calendar cal2 = Calendar.getInstance();
cal2.set(Calendar.YEAR, 2030);
System.out.println("future date = " + cal2.getTime());
/*
* Parameters:
*
* obj - the object to compare with.
*
* Returns:
*
* true if this object is equal to obj; false otherwise.
*/
boolean isEqual = cal1.equals(cal2);
System.out.println("is cal1 equals cal2 = " + isEqual);
}
}
public class CalendarDemo
{
public static void main(String[] args)
{
Calendar cal1 = Calendar.getInstance();
System.out.println("Current date = " + cal1.getTime());
Calendar cal2 = Calendar.getInstance();
cal2.set(Calendar.YEAR, 2030);
System.out.println("future date = " + cal2.getTime());
/*
* Parameters:
*
* obj - the object to compare with.
*
* Returns:
*
* true if this object is equal to obj; false otherwise.
*/
boolean isEqual = cal1.equals(cal2);
System.out.println("is cal1 equals cal2 = " + isEqual);
}
}
Output
Current date = Tue Jul 03 09:47:27 IST 2018
future date = Wed Jul 03 09:47:34 IST 2030
is cal1 equals cal2 = false
future date = Wed Jul 03 09:47:34 IST 2030
is cal1 equals cal2 = false
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/CalendarDemo_equals.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/CalendarDemo_equals
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/b1e669f4abac38a0eb65bfeb213dca88c58230cc/BasicJava_2018/CalendarDemo_equals/?at=master
See also:
No comments:
Post a Comment