GregorianCalendar toString() in Java

toString(): This method is available in java.util.GregorianCalendar class of Java.

Syntax:

String java.util.Calendar.toString()

This method returns a string representation of this calendar.

Parameters: NA

Returns: a string representation of this calendar.

Exceptions: NA

Approach

Java

import java.util.GregorianCalendar;

public class GregorianCalendartoString {
    public static void main(String[] args) {

        GregorianCalendar cal = new GregorianCalendar();

        System.out.println(cal.toString());
    }
}

Output:

java.util.GregorianCalendar[time=1645199773311,areFieldsSet=true,areAllFieldsSet=true,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=2022,MONTH=1,WEEK_OF_YEAR=8,WEEK_OF_MONTH=3,DAY_OF_MONTH=18,DAY_OF_YEAR=49,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=9,HOUR_OF_DAY=21,MINUTE=26,SECOND=13,MILLISECOND=311,ZONE_OFFSET=19800000,DST_OFFSET=0]


No comments:

Post a Comment