クラス JobTimestamp

  • すべての実装されたインタフェース:
    Jsonifiable, java.lang.Comparable<JobTimestamp>

    public final class JobTimestamp
    extends java.lang.Object
    implements java.lang.Comparable<JobTimestamp>, Jsonifiable
    JobTimestamp wraps an instance of java.time.LocalDateTime and associates a fixed instance of java.time.format.DateTimeFormatter to be used. The DateTimeFormat uses a format "uuuuMMdd_HHmmss". The toString() method will return a String, for example, "20221129_110345".
    • フィールドの詳細

      • EPOCH_NAME

        public static final java.lang.String EPOCH_NAME
        special value that represents a NULL object.
        関連項目:
        定数フィールド値
      • FORMATTER

        public static final java.time.format.DateTimeFormatter FORMATTER
    • コンストラクタの詳細

      • JobTimestamp

        public JobTimestamp​(java.lang.String jobTimestamp)
        Sole constructor
        パラメータ:
        jobTimestamp - yyyymmdd_hhMMss e.g. "20210718_091328"; or "_"
    • メソッドの詳細

      • isValid

        public static boolean isValid​(java.lang.String s)
        verifies if the given string is in the format of the FORMATTER, and returns true or false. A under-bar "_" is accepted as the only exception, which stands for the case where no concrete JobTimestamp is given.
        パラメータ:
        s - for example, "20221123_094521"
        戻り値:
        true if the s is in a valid format as JobTimestamp. otherwise false.
      • now

        public static JobTimestamp now()
        戻り値:
        an instance of JobTimestamp with the value of java.time.LocalDateTime.now()
      • create

        public static JobTimestamp create​(java.time.LocalDateTime theTimestamp)
        パラメータ:
        theTimestamp - a JobTimestamp to copy
        戻り値:
        a new JobTimestamp with value of theTimestamp as LocalDateTime
      • epoch

        public static JobTimestamp epoch()
        戻り値:
        a special instance of JobName of which value is a String "_" (under-bar).
      • max

        public static JobTimestamp max​(JobTimestamp... timestamps)
        パラメータ:
        timestamps - a list of JobTimestamps to look at
        戻り値:
        the newest JobTimestamp value among the given timestamps
      • laterThan

        public static JobTimestamp laterThan​(JobTimestamp... previous)
        パラメータ:
        previous - a list of JobTimestamps as comparison basis
        戻り値:
        a new JobTimestamp value which is assured to be newer than any of previous JobTimestamps. If JobTimestamp.now() is newer than them, then the value of JobTimestamp.now() will be returned. If JobTimestamp.now() is equal to the maximum of previous timestamp, the max value will be returned.
      • theTimeOrLaterThan

        public static JobTimestamp theTimeOrLaterThan​(JobTimestamp thanThis,
                                                      JobTimestamp theTime)
        When thanThis is "20221130_010101" and theTime is "20221130_010105", then a JobTimestamp of "20221130_010105" will be returned. When thanThis is "20221130_010101" and theTime is "20221130_010100", then a JobTimestamp of "20221130_010102", which is equal to (thanThis + 1 second), will be returned. When thanThis is "20221130_010101" and theTime is "20221130_010101", then a JobTimestamp of "20221130_010101" will be returned.
        パラメータ:
        thanThis - a JobTimestamp as basis
        theTime - a JobTimestamp
        戻り値:
        a new JobTimestamp value which is assured to be newer thanThis at least for 1 second or more.
      • betweenSeconds

        public static long betweenSeconds​(JobTimestamp previous,
                                          JobTimestamp following)
        calculate the time distance between following and previous in seconds.
        パラメータ:
        previous - e.g, 20221123_080000
        following - e.g, 20221123_080130
        戻り値:
        the seconds between the following minus the previous. E.g, (20221123_080130 - 20221123_080000) should return 90.
      • minus

        public JobTimestamp minus​(long amountToSubtract,
                                  java.time.temporal.TemporalUnit unit)
      • minusDays

        public JobTimestamp minusDays​(long days)
        パラメータ:
        days - number of days backward. E.g, 3 days.
        戻り値:
        a new JobTimestamp instance with the value which is "days" before this JobTimestamp instance.
      • minusHours

        public JobTimestamp minusHours​(long hours)
        パラメータ:
        hours - number of hours backward. E.g, 5 hours.
        戻り値:
        a new JobTimestamp instance with the value which is "hours" before this JobTimestamp instance.
      • minusMinutes

        public JobTimestamp minusMinutes​(long minutes)
        パラメータ:
        minutes - number of minutes backward. E.g, 4 minutes.
        戻り値:
        a new JobTimestamp instance with the value which is "minutes" before this JobTimestamp instance.
      • minusMonths

        public JobTimestamp minusMonths​(long months)
        パラメータ:
        months - nuber of months back. E.g, 2 months.
        戻り値:
        a new JobTimestamp instance with the value which is "months" before this JobTimestamp instance.
      • minusSeconds

        public JobTimestamp minusSeconds​(long seconds)
        パラメータ:
        seconds - number of seconds back. E.g, 10 seconds.
        戻り値:
        a new JobTimestamp instance with the value which is "seconds" before this JobTimestamp instance.
      • minusWeeks

        public JobTimestamp minusWeeks​(long weeks)
        パラメータ:
        weeks - number of weeks back. E.g, 3 weeks.
        戻り値:
        a new JobTimestamp instance with the value which is "weeks" before this JobTimestamp instance.
      • plus

        public JobTimestamp plus​(long amountToAdd,
                                 java.time.temporal.TemporalUnit unit)
      • plusDays

        public JobTimestamp plusDays​(long days)
        パラメータ:
        days - number of days ahead. E.g, 2 days.
        戻り値:
        a new JobTimestamp instance with the value which is "days" after this JobTimestamp instance.
      • plusHours

        public JobTimestamp plusHours​(long hours)
        パラメータ:
        hours - number of hours ahead. E.g, 3 hours.
        戻り値:
        a new JobTimestamp instance with the value which is "hours" after this JobTimestamp instance.
      • plusMinutes

        public JobTimestamp plusMinutes​(long minutes)
        パラメータ:
        minutes - number of minutes ahead. E.g, 2 minutes
        戻り値:
        a new JobTimestamp instance with the value which is "minutes" after this JobTimestamp instance.
      • plusMonths

        public JobTimestamp plusMonths​(long months)
        パラメータ:
        months - number of months ahead. E.g, 2 months
        戻り値:
        a new JobTimestamp instance with the value which is "months" after this JobTimestamp instance.
      • plusSeconds

        public JobTimestamp plusSeconds​(long seconds)
        パラメータ:
        seconds - number of seconds ahead. E.g, 5 seconds.
        戻り値:
        a new JobTimestamp instance with the value which is "seconds" after this JobTimestamp instance.
      • plusWeeks

        public JobTimestamp plusWeeks​(long weeks)
        パラメータ:
        weeks - number of weeks ahead. E.g, 3 weeks
        戻り値:
        a new JobTimestamp instance with the value which is "weeks" after this JobTimestamp instance.
      • withSecond

        public JobTimestamp withSecond​(int second)
        パラメータ:
        second - 0..59
        戻り値:
        a copy of this JobTimestamp instance but with the given second value
      • withMinute

        public JobTimestamp withMinute​(int minute)
        パラメータ:
        minute - 0..59
        戻り値:
        a copy of this JobTimestamp instance but with the given minute value
      • withHour

        public JobTimestamp withHour​(int hour)
        パラメータ:
        hour - 0..23
        戻り値:
        a copy of this JobTimestamp instance but with the given hour value
      • beginningOfTheMonth

        public JobTimestamp beginningOfTheMonth()
        戻り値:
        a new JobTimestamp instance with the value which is the beginning of the month in which this JobTimestamp instance belongs. The hours will be 00, the minutes will be 00, the seconds will be 00.
      • endOfTheMonth

        public JobTimestamp endOfTheMonth()
        戻り値:
        a new JobTimestamp instance with the value which is the last day of the month in which this JobTimestamp instance belongs. The hours will be 23, the minutes will be 59, the seconds will be 59.
      • equals

        public boolean equals​(java.lang.Object obj)
        オーバーライド:
        equals クラス内 java.lang.Object
      • hashCode

        public int hashCode()
        オーバーライド:
        hashCode クラス内 java.lang.Object
      • toString

        public java.lang.String toString()
        E.g, 20221129_195423 represents the year 2022, the month 11, the day 29, the hours 19, the minutes 54, the second 23.
        オーバーライド:
        toString クラス内 java.lang.Object
      • toJson

        public java.lang.String toJson()
        定義:
        toJson インタフェース内 Jsonifiable
        戻り値:
        "20221129_195423" enclosed by double-quotes
      • toJson

        public java.lang.String toJson​(boolean prettyPrint)
        定義:
        toJson インタフェース内 Jsonifiable
      • value

        public java.time.LocalDateTime value()
        If the value is the special "_", then LocalDateTime.ofEpochSecond(0L, 0, ZoneOffset.UTC) will be returned
        戻り値:
        the LocalDateTime value of this instance
      • compareTo

        public int compareTo​(JobTimestamp other)
        定義:
        compareTo インタフェース内 java.lang.Comparable<JobTimestamp>