Class MatomoDate

java.lang.Object
org.matomo.java.tracking.MatomoDate
Direct Known Subclasses:
PiwikDate

public class MatomoDate extends Object
A datetime object that will return the datetime in the format yyyy-MM-dd hh:mm:ss.
Author:
brettcsorba
  • Constructor Summary

    Constructors
    Constructor
    Description
    Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.
    MatomoDate(long epochMilli)
    Allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Converts this datetime to the number of milliseconds from the epoch of 1970-01-01T00:00:00Z.
    void
    Sets the time zone of the String that will be returned by toString().
    Converts this MatomoDate object to a String of the form:

    yyyy-MM-dd hh:mm:ss.

    Methods inherited from class java.lang.Object

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

    • MatomoDate

      public MatomoDate()
      Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.
    • MatomoDate

      public MatomoDate(long epochMilli)
      Allocates a Date object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.
      Parameters:
      epochMilli - the milliseconds since January 1, 1970, 00:00:00 GMT.
  • Method Details

    • setTimeZone

      public void setTimeZone(ZoneId zone)
      Sets the time zone of the String that will be returned by toString(). Defaults to UTC.
      Parameters:
      zone - the TimeZone to set
    • toString

      public String toString()
      Converts this MatomoDate object to a String of the form:

      yyyy-MM-dd hh:mm:ss.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this MatomoDate
    • getTime

      public long getTime()
      Converts this datetime to the number of milliseconds from the epoch of 1970-01-01T00:00:00Z.
      Returns:
      the number of milliseconds since the epoch of 1970-01-01T00:00:00Z
      Throws:
      ArithmeticException - if numeric overflow occurs