Class DateTime

  • All Implemented Interfaces:
    Serializable, Cloneable, Comparable<DateTime>, IDate

    public class DateTime
    extends Object
    implements IDate, Comparable<DateTime>, Cloneable, Serializable
    Mutable class used to represent dates in the Cyclos API instead of Date.
    It represents a specific instant in time in a specific time zone (e.g.: the client TZ) with millisecond precision. It works in 'lenient' mode similar to the corresponding Calendar's mode with the difference that for inconsistent fields no exception is thrown.
    • Year
    • Month (month of year):valid values are in the range 0 (January) - 11 (December)
    • Date (day of month): valid values are in the range 1-31
    • Hours (hour in day): valid values are in the range 0-23
    • Minutes: valid values are in the range 0-59
    • Seconds: valid values are in the range 0-59
    • Milliseconds: (within the second) valid values are in the range 0-999
    See Also:
    Serialized Form
    • Constructor Detail

      • DateTime

        public DateTime()
      • DateTime

        public DateTime​(int year,
                        int month,
                        int date)
        Constructs a DateTime with zero in the time fields (HMS).
        Parameters:
        month - it must be between 0 and 11 (same as Date)
        date - it must be between 1 and 31 (same as Date)
      • DateTime

        public DateTime​(int year,
                        int month,
                        int date,
                        int hours,
                        int minutes)
        Constructs a DateTime with zero in the time fields (HMS).
        Parameters:
        month - it must be between 0 and 11 (same as Date)
        date - it must be between 1 and 31 (same as Date)
        hours - it must be between 0 and 23 (Hour in day)
        minutes - it must be between 0 and 59
      • DateTime

        public DateTime​(int year,
                        int month,
                        int date,
                        int hours,
                        int minutes,
                        int seconds)
        Constructs a DateTime with zero in the time fields (HMS).
        Parameters:
        month - it must be between 0 and 11 (same as Date)
        date - it must be between 1 and 31 (same as Date)
        hours - it must be between 0 and 23 (Hour in day)
        minutes - it must be between 0 and 59
        seconds - it must be between 0 and 59
      • DateTime

        public DateTime​(int year,
                        int month,
                        int date,
                        int hours,
                        int minutes,
                        int seconds,
                        int millis)
        Constructs a DateTime with all its fields initialized.
        Parameters:
        month - it must be between 0 and 11 (same as Date)
        date - it must be between 1 and 31 (same as Date)
        hours - it must be between 0 and 23 (Hour in day)
        minutes - it must be between 0 and 59
        seconds - it must be between 0 and 59
        millis - it must be between 0 and 999
      • DateTime

        public DateTime​(int year,
                        int month,
                        int date,
                        int hours,
                        int minutes,
                        int seconds,
                        int millis,
                        String timeZone)
        Constructs a DateTime with all its fields initialized.
        Parameters:
        month - it must be between 0 and 11 (same as Date)
        date - it must be between 1 and 31 (same as Date)
        hours - it must be between 0 and 23 (Hour in day)
        minutes - it must be between 0 and 59
        seconds - it must be between 0 and 59
        millis - it must be between 0 and 999
        timeZone - the timezone. Null means resolving the current user's configured timezone
      • DateTime

        public DateTime​(String string)
      • DateTime

        public DateTime​(String string,
                        boolean fillToDayEnd)
    • Method Detail

      • parse

        public static DateTime parse​(String string)
        Parses the given String as a DateTime, returning null for blank strings
      • after

        public boolean after​(DateTime dt)
      • afterOrEquals

        public boolean afterOrEquals​(DateTime dt)
      • before

        public boolean before​(DateTime dt)
      • beforeOrEquals

        public boolean beforeOrEquals​(DateTime dt)
      • duplicate

        public DateTime duplicate()
        Makes a copy of this instance.
      • getDate

        public int getDate()
      • getHours

        public int getHours()
      • getMilliseconds

        public int getMilliseconds()
      • getMinutes

        public int getMinutes()
      • getMonth

        public int getMonth()
      • getSeconds

        public int getSeconds()
      • getTimeZone

        public String getTimeZone()
      • getYear

        public int getYear()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • isSameDay

        public boolean isSameDay​(DateTime dt)
      • setDate

        public void setDate​(int date)
        Sets the day of the month.
        Parameters:
        date - it must be between 1 and 31 (must be a valid value according to the month)
      • setHMSM

        public void setHMSM​(int hours,
                            int minutes,
                            int seconds,
                            int milliseconds)
        Sets only the time part (H=hours, M=minutes, S=seconds, M=milliseconds) without changing the date part (YMD)
        Parameters:
        hours - it must be between 0 and 23 (Hour in day)
      • setHours

        public void setHours​(int hours)
        Parameters:
        hours - it must be between 0 and 23 (Hour in day)
      • setMilliseconds

        public void setMilliseconds​(int milliseconds)
      • setMinutes

        public void setMinutes​(int minutes)
        Parameters:
        minutes - it must be between 0 and 59
      • setMonth

        public void setMonth​(int month)
        Parameters:
        month - it must be between 0 and 11 (same as Date)
      • setSeconds

        public void setSeconds​(int seconds)
        Parameters:
        seconds - it must be between 0 and 59
      • setTimeZone

        public void setTimeZone​(String timeZone)
      • setYear

        public void setYear​(int year)
      • setYMD

        public void setYMD​(int year,
                           int month,
                           int date)
        Sets only the date part (Y=year, M=month, D=date (day of month)) without change the time part (HMS)
        Parameters:
        month - it must be between 0 and 11 (same as Date)
        date - it must be between 1 and 31 (same as Date)
      • toDateString

        public String toDateString()
      • toLocalDate

        public LocalDate toLocalDate()
      • toTimeString

        public String toTimeString()