Class SkriptDate

java.lang.Object
io.github.syst3ms.skriptparser.util.SkriptDate
All Implemented Interfaces:
Comparable<SkriptDate>

public class SkriptDate extends Object implements Comparable<SkriptDate>
  • Field Details

  • Method Details

    • now

      public static SkriptDate now()
      Creates a new SkriptDate of the current time.
      Returns:
      the date
    • of

      public static SkriptDate of(long timestamp)
      Creates a new SkriptDate with a specific timestamp. Note that timestamps are expressed in milliseconds. The timestamp is internally stored as a date in the UTC time zone. Use this method if you wish to take a non-default time zone into account.
      Parameters:
      timestamp - the timestamp
      Returns:
      the date
    • of

      public static SkriptDate of(long timestamp, TimeZone zone)
      Creates a new SkriptDate with a specific timestamp. Note that timestamps are expressed in milliseconds. The zone offset is taken into account when calculating the final timestamp.
      Parameters:
      timestamp - the timestamp
      zone - the time zone
      Returns:
      the date
    • today

      public static SkriptDate today()
      Creates a new SkriptDate of the current date at midnight. Note that this takes the default time zone into account. Use this method if you want to use a non-default time zone.
      Returns:
      the date
    • today

      public static SkriptDate today(TimeZone zone)
      Creates a new SkriptDate of the current date at midnight in a specific time zone.
      Parameters:
      zone - the zone
      Returns:
      the date
    • getDefaultTimeZone

      public static TimeZone getDefaultTimeZone()
      Returns:
      the default system time zone
    • getTimestamp

      public long getTimestamp()
      Returns:
      the amount of milliseconds that have passed since midnight, January 1st, 1970 in the UTC time zone
    • difference

      public Duration difference(SkriptDate other)
      Returns the duration between the given dates.
      Parameters:
      other - the other date
      Returns:
      the duration
    • add

      public void add(Duration duration)
      Adds a specific duration to this date. A negative duration will subtract instead.
      Parameters:
      duration - the duration
    • subtract

      public void subtract(Duration duration)
      Subtracts a specific duration from this date. A negative duration will add instead.
      Parameters:
      duration - the duration
    • plus

      public SkriptDate plus(Duration duration)
      Adds a specific duration to this date and returns the result of this addition. A negative duration will subtract instead.
      Parameters:
      duration - the duration
      Returns:
      the date
    • minus

      public SkriptDate minus(Duration duration)
      Subtracts a specific duration from this date and returns the result of this subtraction. A negative duration will add instead.
      Parameters:
      duration - the duration
      Returns:
      the date
    • toLocalDateTime

      public LocalDateTime toLocalDateTime()
      Returns this date as a LocalDate.
      Returns:
      the LocalDate of this date
    • compareTo

      public int compareTo(@Nullable @Nullable SkriptDate other)
      Specified by:
      compareTo in interface Comparable<SkriptDate>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toString

      public String toString(String format)
      Returns the string representation of this date using a certain format.
      Parameters:
      format - the format
      Returns:
      the string representation of this date
    • equals

      public boolean equals(@Nullable @Nullable Object obj)
      Overrides:
      equals in class Object