Click here to watch on Youtube:
https://www.youtube.com/watch?v=vdMsZUUp75k&list=UUhwKlOVR041tngjerWxVccw
GregorianCalendarDemo.java
Output
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/GregorianCalendarDemo_add_amount.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/GregorianCalendarDemo_add_amount
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/4cfac93378c4f9d33f18bb5083115d18778294de/BasicJava_2018/GregorianCalendarDemo_add_amount/?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=vdMsZUUp75k&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(cal.getTime());
/*
* Parameters:
*
* field - the calendar field.
*
* amount - the amount of date or time to be added to the
* field.
*/
// add 2 months
cal.add(GregorianCalendar.MONTH, 2);
System.out.println(cal.getTime());
// add 2 years
cal.add(GregorianCalendar.YEAR, 2);
System.out.println(cal.getTime());
}
}
public class GregorianCalendarDemo
{
public static void main(String[] args)
{
GregorianCalendar cal = (GregorianCalendar) GregorianCalendar
.getInstance();
System.out.println(cal.getTime());
/*
* Parameters:
*
* field - the calendar field.
*
* amount - the amount of date or time to be added to the
* field.
*/
// add 2 months
cal.add(GregorianCalendar.MONTH, 2);
System.out.println(cal.getTime());
// add 2 years
cal.add(GregorianCalendar.YEAR, 2);
System.out.println(cal.getTime());
}
}
Output
Thu Oct 11 08:50:55 IST 2018
Tue Dec 11 08:50:55 IST 2018
Fri Dec 11 08:50:55 IST 2020
Tue Dec 11 08:50:55 IST 2018
Fri Dec 11 08:50:55 IST 2020
Click the below link to download the code:
https://sites.google.com/site/ramj2eev2/java_basics/GregorianCalendarDemo_add_amount.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava_2018/GregorianCalendarDemo_add_amount
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/4cfac93378c4f9d33f18bb5083115d18778294de/BasicJava_2018/GregorianCalendarDemo_add_amount/?at=master
See also:
No comments:
Post a Comment