Package java.util

Class GregorianCalendar

java.lang.Object
java.util.Calendar
java.util.GregorianCalendar
All Implemented Interfaces:
Cloneable

public class GregorianCalendar extends Calendar implements Cloneable
  • Field Details

    • BC

      public static final int BC
      Value of the ERA field indicating the period before the common era (before Christ), also known as BCE. The sequence of years at the transition from BC to AD is ..., 2 BC, 1 BC, 1 AD, 2 AD,...
      See Also:
    • ONE_DAY

      protected static final long ONE_DAY
      See Also:
  • Constructor Details

    • GregorianCalendar

      public GregorianCalendar()
  • Method Details

    • clone

      public Object clone()
      Specified by:
      clone in class Calendar
    • clear

      public void clear()
      Specified by:
      clear in class Calendar
    • computeFields

      public void computeFields()
    • computeTime

      public void computeTime()
    • getTime

      public Date getTime()
      Description copied from class: Calendar
      Returns a Date object representing this Calendar's time value (millisecond offset from the Epoch").
      Specified by:
      getTime in class Calendar
      Returns:
      a Date representing the time value.
      See Also:
    • setTime

      public void setTime(Date date)
      Description copied from class: Calendar
      Sets this Calendar's time with the given Date.

      Note: Calling setTime() with Date(Long.MAX_VALUE) or Date(Long.MIN_VALUE) may yield incorrect field values from get().

      Specified by:
      setTime in class Calendar
      Parameters:
      date - the given Date.
      See Also:
    • setTimeInMillis

      public void setTimeInMillis(long millis)
      Description copied from class: Calendar
      Sets this Calendar's current time from the given long value.
      Specified by:
      setTimeInMillis in class Calendar
      Parameters:
      millis - the new time in UTC milliseconds from the epoch.
      See Also:
    • getTimeInMillis

      public long getTimeInMillis()
      Description copied from class: Calendar
      Returns this Calendar's time value in milliseconds.
      Specified by:
      getTimeInMillis in class Calendar
      Returns:
      the current time as UTC milliseconds from the epoch.
      See Also:
    • get

      public int get(int field)
      Specified by:
      get in class Calendar
    • set

      public void set(int field, int value)
      Description copied from class: Calendar
      Sets the given calendar field to the given value. The value is not interpreted by this method regardless of the leniency mode.
      Specified by:
      set in class Calendar
      Parameters:
      field - the given calendar field.
      value - the value to be set for the given calendar field.
      See Also:
    • add

      public void add(int field, int value)
      Specified by:
      add in class Calendar