« Date
Calendar.toString() String output of Calendar object .
Returns the copy of the toStringd object.
The method Set() is used to assign calendar fields .
Examples with output
package my_proj;
import java.util.Calendar;
public class my_first {
public static void main(String[] args) {
Calendar my_cal_d1 = Calendar.getInstance();// created calendar
my_cal_d1.set(2025,4,28,10,11,12);
System.out.println( my_cal_d1.getTime());
System.out.println( my_cal_d1.getTime().toString());
System.out.println( my_cal_d1.toString());
}
}
OutputWed May 28 10:11:12 IST 2025
Wed May 28 10:11:12 IST 2025
java.util.GregorianCalendar[time=1748407272138,
areFieldsSet=true,areAllFieldsSet=false,
lenient=true,zone=sun.util.calendar.ZoneInfo[id="Asia/Calcutta",
offset=19800000,dstSavings=0,useDaylight=false,transitions=7,
lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,
YEAR=2025,MONTH=4,WEEK_OF_YEAR=22,WEEK_OF_MONTH=5,DAY_OF_MONTH=28,
DAY_OF_YEAR=148,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=4,AM_PM=0,
HOUR=10,HOUR_OF_DAY=10,MINUTE=11,SECOND=12,MILLISECOND=138,
ZONE_OFFSET=19800000,DST_OFFSET=0]
« Date & time tutorials