Class ISOCalendar

All Implemented Interfaces:
Serializable

public class ISOCalendar extends GregorianCalendar
Implementation of the ISO 8601 week-date calendar. The ISO week-date system is an international standard for representing dates using week numbers instead of months.

Key features:

  • Year-week-day format (e.g., 2024-W01-1)
  • Weeks start on Monday (day 1) and end on Sunday (day 7)
  • Week 1 contains January 4th (or the first Thursday of January)
  • Years have either 52 or 53 weeks
* @version 2.0
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
See Also:
  • Constructor Details

    • ISOCalendar

      public ISOCalendar(long l)
      Creates a new ISOCalendar object.
      Parameters:
      l - the Rata Die number.
    • ISOCalendar

      public ISOCalendar(int i, int j, int k)
      Creates a new ISOCalendar object.
      Parameters:
      i - the week number.
      j - the day of week.
      k - the year.
    • ISOCalendar

      public ISOCalendar()
      Creates a new ISOCalendar object.
    • ISOCalendar

      public ISOCalendar(AlternateCalendar altcalendar)
      Creates a new ISOCalendar object.
      Parameters:
      altcalendar - another calendar to initialize from.
  • Method Details

    • set

      public void set(int i, int j, int k)
      Sets the ISO week components and recomputes the date.
      Overrides:
      set in class MonthDayYear
      Parameters:
      i - the week.
      j - the day.
      k - the year.
    • getYear

      public int getYear()
      Returns the ISO year.
      Overrides:
      getYear in class MonthDayYear
      Returns:
      the year.
    • recomputeRD

      protected void recomputeRD()
      Recomputes the Rata Die number from current week components.
      Overrides:
      recomputeRD in class GregorianCalendar
    • recomputeFromRD

      protected void recomputeFromRD()
      Recomputes the ISO week components from the current Rata Die number.
      Overrides:
      recomputeFromRD in class GregorianCalendar
    • getWeek

      public int getWeek()
      Returns the ISO week number.
      Returns:
      the week number (1-53).
    • getDay

      public int getDay()
      Returns the ISO day number.
      Overrides:
      getDay in class MonthDayYear
      Returns:
      the day number (1-7).
    • toString

      public String toString()
      Returns a string representation of the ISO week-date.
      Overrides:
      toString in class GregorianCalendar
      Returns:
      the date string.
    • getMonth

      public int getMonth()
      Returns 0 as ISO weeks are not defined within standard months.
      Overrides:
      getMonth in class MonthDayYear
      Returns:
      0.
    • main

      public static void main(String[] args)
      Main method for testing the ISOCalendar implementation.
      Parameters:
      args - command line arguments.