Click here to watch on Youtube: 
https://www.youtube.com/watch?v=Xp8Ckh8CoQI&list=UUhwKlOVR041tngjerWxVccw
GregorianCalendarDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/GregorianCalendarDemo_roll_up_indicator.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/4cfac93378c4f9d33f18bb5083115d18778294de/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/?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=Xp8Ckh8CoQI&list=UUhwKlOVR041tngjerWxVccw
GregorianCalendarDemo.java
import java.util.GregorianCalendar;
public class GregorianCalendarDemo
{
public static void main(String[] args)
{
GregorianCalendar cal = (GregorianCalendar) GregorianCalendar
.getInstance();
System.out.println("Date = "+cal.getTime());
/*
* Parameters:
*
* field - the time field.
*
* up - indicates if the value of the specified calendar field
* is to be rolled up or rolled down. Use true if rolling up,
* false otherwise.
*/
// roll a month forward
cal.roll(GregorianCalendar.MONTH, true);
System.out.println("Date = " + cal.getTime());
// roll a year backwards
cal.roll(GregorianCalendar.YEAR, false);
System.out.println("Date = " + cal.getTime());
}
}
public class GregorianCalendarDemo
{
public static void main(String[] args)
{
GregorianCalendar cal = (GregorianCalendar) GregorianCalendar
.getInstance();
System.out.println("Date = "+cal.getTime());
/*
* Parameters:
*
* field - the time field.
*
* up - indicates if the value of the specified calendar field
* is to be rolled up or rolled down. Use true if rolling up,
* false otherwise.
*/
// roll a month forward
cal.roll(GregorianCalendar.MONTH, true);
System.out.println("Date = " + cal.getTime());
// roll a year backwards
cal.roll(GregorianCalendar.YEAR, false);
System.out.println("Date = " + cal.getTime());
}
}
Output
Date = Wed Oct 10 09:09:11 IST 2018
Date = Sat Nov 10 09:09:11 IST 2018
Date = Fri Nov 10 09:09:11 IST 2017
Date = Sat Nov 10 09:09:11 IST 2018
Date = Fri Nov 10 09:09:11 IST 2017
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/GregorianCalendarDemo_roll_up_indicator.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/4cfac93378c4f9d33f18bb5083115d18778294de/BasicJava_2018/GregorianCalendarDemo_roll_up_indicator/?at=master
See also:

No comments:
Post a Comment