Class CustomDate

java.lang.Object
tk.airshipcraft.commonlib.calendar.clock.CustomDate

public class CustomDate extends Object
Represents a date in the custom calendar system used in the AirshipCraft Minecraft server. This custom calendar system defines a year as consisting of 12 months, each with 24 days, leading to a 288-day year. This class provides functionalities for handling dates within this unique calendar system, including operations like adding days and converting between the custom calendar and the Gregorian calendar.

Key characteristics of the custom calendar:

  • Months per Year: 12 months
  • Days per Month: 24 days
  • Total Days per Year: 288 days (12 months * 24 days per month)

The CustomDate class also includes methods to convert Minecraft day counts to CustomDate, considering each Minecraft day as a full day in the custom calendar.

Example Usage:


 CustomDate date = new CustomDate(1, 1, 1); // Start of Year 1
 date.addDays(10); // Advances the date by 10 days within the custom calendar
 LocalDate equivalentGregorianDate = date.toLocalDate(); // Converts to the Gregorian calendar date
 
Since:
2024-01-04
Version:
1.0.0
Author:
notzune
  • Constructor Summary

    Constructors
    Constructor
    Description
    CustomDate(int year, int month, int day)
    Initializes a new CustomDate.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addDays(int days)
    Adds the specified number of days to the current date.
    int
    Calculates the number of days from this date to another date.
    boolean
    Compares this CustomDate to another CustomDate.
    static CustomDate
    fromMinecraftDays(long minecraftDays)
    Converts the number of Minecraft days since a fixed epoch to a CustomDate.
    int
    Returns the day of the month represented by this CustomDate.
    int
    Returns the month represented by this CustomDate.
    int
    Returns the year represented by this CustomDate.
    int
    Returns a hash code for this CustomDate.
    void
    setDay(int day)
    Sets the day of the month represented by this CustomDate.
    void
    setMonth(int month)
    Sets the month represented by this CustomDate.
    void
    setYear(int year)
    Sets the year represented by this CustomDate.
    Returns a string representation of this CustomDate.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • CustomDate

      public CustomDate(int year, int month, int day)
      Initializes a new CustomDate.
      Parameters:
      year - The year.
      month - The month.
      day - The day.
  • Method Details

    • fromMinecraftDays

      public static CustomDate fromMinecraftDays(long minecraftDays)
      Converts the number of Minecraft days since a fixed epoch to a CustomDate. Assumes each Minecraft day corresponds to one day in the custom calendar.
      Parameters:
      minecraftDays - The number of Minecraft days since the epoch.
      Returns:
      The CustomDate representing the equivalent date since the epoch.
    • addDays

      public void addDays(int days)
      Adds the specified number of days to the current date.
      Parameters:
      days - The number of days to add.
    • daysUntil

      public int daysUntil(CustomDate other)
      Calculates the number of days from this date to another date.
      Parameters:
      other - The date to calculate the days to.
      Returns:
      The number of days until the other date.
    • equals

      public boolean equals(Object obj)
      Compares this CustomDate to another CustomDate.
      Overrides:
      equals in class Object
      Parameters:
      obj - The other CustomDate to compare to.
      Returns:
      true if the dates are equal, false otherwise
    • hashCode

      public int hashCode()
      Returns a hash code for this CustomDate.
      Overrides:
      hashCode in class Object
      Returns:
      A hash code value for this CustomDate.
    • toString

      public String toString()
      Returns a string representation of this CustomDate.
      Overrides:
      toString in class Object
      Returns:
      A string representation of this CustomDate.
    • getDay

      public int getDay()
      Returns the day of the month represented by this CustomDate.
      Returns:
      The day of the month represented by this CustomDate.
    • setDay

      public void setDay(int day)
      Sets the day of the month represented by this CustomDate.
      Parameters:
      day - The day of the month to set.
    • getMonth

      public int getMonth()
      Returns the month represented by this CustomDate.
      Returns:
      The month represented by this CustomDate.
    • setMonth

      public void setMonth(int month)
      Sets the month represented by this CustomDate.
      Parameters:
      month - The month to set.
    • getYear

      public int getYear()
      Returns the year represented by this CustomDate.
      Returns:
      The year represented by this CustomDate.
    • setYear

      public void setYear(int year)
      Sets the year represented by this CustomDate.
      Parameters:
      year - The year to set.