10:59 pm - Thursday February 23, 2017

Calendar in java example program set(int year, int month, int date, int hour, int minute, int second)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/**

*@author:candidjava.com
*@description: Calender in java example program set(int year,int month,int date,int hour,int minute,int second)
*/
import java.util.Calendar;
public class CalendarSet {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance(); // create a calendar
System.out.println("Current year is :" + cal.getTime()); // print current time
cal.set(2001, 7, 23, 05, 17, 24); // set the year,month and day to something else
System.out.println("Altered year is :" + cal.getTime()); // print the result
}
}

//OUTPUT:

Current year is :Sat Dec 01 07:35:53 GMT 2012
Altered year is :Thu Aug 23 05:17:24 GMT 2001

BACK

Filed in: Z-A All Java Codes

Comments are closed.