Class Date

java.lang.Object
java.util.Date
ch.njol.skript.util.Date
All Implemented Interfaces:
YggdrasilSerializable, Serializable, Cloneable, Comparable<Date>

public class Date extends Date implements YggdrasilSerializable
See Also:
  • Constructor Details

    • Date

      public Date()
      Creates a new Date with the current time.
    • Date

      public Date(long timestamp)
      Creates a new Date with the provided timestamp.
      Parameters:
      timestamp - The timestamp in milliseconds.
    • Date

      public Date(long timestamp, TimeZone zone)
      Creates a new Date with the provided timestamp and timezone.
      Parameters:
      timestamp - The timestamp in milliseconds.
      zone - The timezone to use.
  • Method Details

    • now

      public static Date now()
      Get a new Date with the current time
      Returns:
      New date with the current time
    • fromJavaDate

      public static Date fromJavaDate(Date date)
      Converts a Date to a Date.
      Parameters:
      date - The Date to convert.
      Returns:
      The converted date.
    • add

      public void add(Timespan other)
      Add a Timespan to this date
      Parameters:
      other - Timespan to add
    • subtract

      public void subtract(Timespan other)
      Subtract a Timespan from this date
      Parameters:
      other - Timespan to subtract
    • difference

      public Timespan difference(Date other)
      Returns the difference between this date and another date as a Timespan.
      Parameters:
      other - The other date.
      Returns:
      The difference between the provided dates as a Timespan.
    • plus

      public Date plus(Timespan other)
      Get a new instance of this Date with the added timespan
      Parameters:
      other - Timespan to add to this Date
      Returns:
      New Date with the added timespan
    • minus

      public Date minus(Timespan other)
      Get a new instance of this Date with the subtracted timespan
      Parameters:
      other - Timespan to subtract from this Date
      Returns:
      New Date with the subtracted timespan
    • getTimestamp

      @Deprecated(forRemoval=true) public long getTimestamp()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use Date.getTime() instead.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Date
    • equals

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

      public String toString()
      Overrides:
      toString in class Date