Package com.helger.commons.datetime
Class PDTFactory
- java.lang.Object
-
- com.helger.commons.datetime.PDTFactory
-
@Immutable public final class PDTFactory extends Object
-
-
Method Summary
-
-
-
Method Detail
-
getTimezoneOffsetInMinutes
public static int getTimezoneOffsetInMinutes(@Nonnull Date aDate)
Get the time zone offset to UTC of the passed Date in minutes to be used inXMLGregorianCalendar.- Parameters:
aDate- The date to use. May not benull.- Returns:
- 0 for no offset to UTC, the minutes otherwise. Usually in 60minutes steps :)
-
getTimezoneOffsetInMinutes
public static int getTimezoneOffsetInMinutes(@Nonnull GregorianCalendar aCal)
-
getTimezoneOffsetInMinutes
public static int getTimezoneOffsetInMinutes(@Nonnull ZoneId aZID, @Nonnull Instant aAt)
-
getTimezoneOffsetInMinutes
public static int getTimezoneOffsetInMinutes(@Nonnull ZoneOffset aZO)
-
getZoneOffsetFromOffsetInMinutes
@Nonnull public static ZoneOffset getZoneOffsetFromOffsetInMinutes(int nOffsetInMinutes)
-
getZoneIdFromOffsetInMinutes
@Nonnull public static ZoneId getZoneIdFromOffsetInMinutes(int nOffsetInMinutes)
-
getCurrentZonedDateTime
@Nonnull public static ZonedDateTime getCurrentZonedDateTime()
-
getWithMillisOnly
@Nullable public static ZonedDateTime getWithMillisOnly(@Nullable ZonedDateTime aODT)
Get the passed date time but with micro and nanoseconds set to 0, so that only the milliseconds part is present. This is helpful for XSD serialization, where only milliseconds granularity is available.- Parameters:
aODT- Source date time. May benull.- Returns:
nullif the parameter isnull, the local date time with microseconds and nanoseconds set to 0 otherwise.- Since:
- 9.2.0
-
getCurrentZonedDateTimeMillisOnly
@Nonnegative public static ZonedDateTime getCurrentZonedDateTimeMillisOnly()
- Returns:
- The current local date and time but with micro and nanoseconds set to 0, so that only the milliseconds part is present. This is helpful for XSD serialization, where only milliseconds granularity is available.
- Since:
- 9.2.0
-
getCurrentZonedDateTimeUTC
@Nonnull public static ZonedDateTime getCurrentZonedDateTimeUTC()
-
getCurrentZonedDateTimeUTCMillisOnly
@Nonnegative public static ZonedDateTime getCurrentZonedDateTimeUTCMillisOnly()
- Returns:
- The current local date and time but with micro and nanoseconds set to 0, so that only the milliseconds part is present. This is helpful for XSD serialization, where only milliseconds granularity is available.
- Since:
- 9.2.0
-
createZonedDateTime
@Nullable public static ZonedDateTime createZonedDateTime(@Nullable OffsetDateTime aODT)
-
createZonedDateTime
@Nullable public static ZonedDateTime createZonedDateTime(@Nullable LocalDateTime aLDT)
-
createZonedDateTime
@Nullable public static ZonedDateTime createZonedDateTime(@Nullable LocalDate aLD)
-
createZonedDateTime
@Nullable public static ZonedDateTime createZonedDateTime(@Nullable YearMonth aYM)
-
createZonedDateTime
@Nullable public static ZonedDateTime createZonedDateTime(@Nullable Year aYear)
-
createZonedDateTime
@Nullable public static ZonedDateTime createZonedDateTime(@Nullable LocalTime aLT)
-
createZonedDateTime
@Nonnull public static ZonedDateTime createZonedDateTime(int nYear, Month eMonth, int nDay)
-
createZonedDateTime
@Nonnull public static ZonedDateTime createZonedDateTime(int nYear, @Nonnull Month eMonth, int nDay, int nHour, int nMinute, int nSecond)
-
createZonedDateTime
@Nullable public static ZonedDateTime createZonedDateTime(@Nullable Instant aInstant)
-
createZonedDateTime
@Nullable public static ZonedDateTime createZonedDateTime(@Nullable GregorianCalendar aCal)
-
createZonedDateTime
@Nullable public static ZonedDateTime createZonedDateTime(@Nullable Date aDate)
-
createZonedDateTime
@Nullable public static ZonedDateTime createZonedDateTime(@Nullable Timestamp aTimestamp)
-
createZonedDateTime
@Nonnull public static ZonedDateTime createZonedDateTime(long nMillis)
-
createZonedDateTime
@Nonnull public static ZonedDateTime createZonedDateTime(@Nullable Number aMillis)
-
getCurrentOffsetDateTime
@Nonnegative public static OffsetDateTime getCurrentOffsetDateTime()
-
getWithMillisOnly
@Nullable public static OffsetDateTime getWithMillisOnly(@Nullable OffsetDateTime aODT)
Get the passed date time but with micro and nanoseconds set to 0, so that only the milliseconds part is present. This is helpful for XSD serialization, where only milliseconds granularity is available.- Parameters:
aODT- Source date time. May benull.- Returns:
nullif the parameter isnull, the local date time with microseconds and nanoseconds set to 0 otherwise.- Since:
- 9.2.0
-
getCurrentOffsetDateTimeMillisOnly
@Nonnegative public static OffsetDateTime getCurrentOffsetDateTimeMillisOnly()
- Returns:
- The current local date and time but with micro and nanoseconds set to 0, so that only the milliseconds part is present. This is helpful for XSD serialization, where only milliseconds granularity is available.
- Since:
- 9.2.0
-
createOffsetDateTime
@Nullable public static OffsetDateTime createOffsetDateTime(@Nullable ZonedDateTime aZDT)
-
createOffsetDateTime
@Nullable public static OffsetDateTime createOffsetDateTime(@Nullable LocalDateTime aLDT)
-
createOffsetDateTime
@Nullable public static OffsetDateTime createOffsetDateTime(@Nullable LocalDate aLD)
-
createOffsetDateTime
@Nullable public static OffsetDateTime createOffsetDateTime(@Nullable YearMonth aYM)
-
createOffsetDateTime
@Nullable public static OffsetDateTime createOffsetDateTime(@Nullable Year aYear)
-
createOffsetDateTime
@Nullable public static OffsetDateTime createOffsetDateTime(@Nullable LocalTime aLT)
-
createOffsetDateTime
@Nonnull public static OffsetDateTime createOffsetDateTime(int nYear, Month eMonth, int nDay)
-
createOffsetDateTime
@Nonnull public static OffsetDateTime createOffsetDateTime(int nYear, @Nonnull Month eMonth, int nDay, int nHour, int nMinute, int nSecond)
-
createOffsetDateTime
@Nullable public static OffsetDateTime createOffsetDateTime(@Nullable Instant aInstant)
-
createOffsetDateTime
@Nullable public static OffsetDateTime createOffsetDateTime(@Nullable Date aDate)
-
createOffsetDateTime
@Nullable public static OffsetDateTime createOffsetDateTime(@Nullable Timestamp aTimestamp)
-
createOffsetDateTime
@Nullable public static OffsetDateTime createOffsetDateTime(@Nullable GregorianCalendar aCal)
-
createOffsetDateTime
@Nonnull public static OffsetDateTime createOffsetDateTime(long nMillis)
-
createOffsetDateTime
@Nullable public static OffsetDateTime createOffsetDateTime(@Nullable Number aMillis)
-
getCurrentLocalDateTime
@Nonnegative public static LocalDateTime getCurrentLocalDateTime()
-
getWithMillisOnly
@Nullable public static LocalDateTime getWithMillisOnly(@Nullable LocalDateTime aLDT)
Get the passed date time but with micro and nanoseconds set to 0, so that only the milliseconds part is present. This is helpful for XSD serialization, where only milliseconds granularity is available.- Parameters:
aLDT- Source date time. May benull.- Returns:
nullif the parameter isnull, the local date time with microseconds and nanoseconds set to 0 otherwise.- Since:
- 9.2.0
-
getCurrentLocalDateTimeMillisOnly
@Nonnegative public static LocalDateTime getCurrentLocalDateTimeMillisOnly()
- Returns:
- The current local date and time but with micro and nanoseconds set to 0, so that only the milliseconds part is present. This is helpful for XSD serialization, where only milliseconds granularity is available.
- Since:
- 9.2.0
-
createLocalDateTime
@Nullable public static LocalDateTime createLocalDateTime(@Nullable ZonedDateTime aDT)
-
createLocalDateTime
@Nullable public static LocalDateTime createLocalDateTime(@Nullable OffsetDateTime aDT)
-
createLocalDateTime
@Nullable public static LocalDateTime createLocalDateTime(@Nullable LocalDate aLD)
-
createLocalDateTime
@Nullable public static LocalDateTime createLocalDateTime(@Nullable YearMonth aYM)
-
createLocalDateTime
@Nullable public static LocalDateTime createLocalDateTime(@Nullable Year aYear)
-
createLocalDateTime
@Nullable public static LocalDateTime createLocalDateTime(@Nullable LocalTime aLT)
-
createLocalDateTime
@Nonnull public static LocalDateTime createLocalDateTime(int nYear, @Nonnull Month eMonth, int nDay)
-
createLocalDateTime
@Nonnull public static LocalDateTime createLocalDateTime(int nYear, @Nonnull Month eMonth, int nDay, int nHour, int nMinute)
-
createLocalDateTime
@Nonnull public static LocalDateTime createLocalDateTime(int nYear, @Nonnull Month eMonth, int nDay, int nHour, int nMinute, int nSecond)
-
createLocalDateTime
@Nullable public static LocalDateTime createLocalDateTime(@Nullable Instant aInstant)
-
createLocalDateTime
@Nullable public static LocalDateTime createLocalDateTime(@Nullable Date aDate)
-
createLocalDateTime
@Nullable public static LocalDateTime createLocalDateTime(@Nullable Timestamp aDate)
-
createLocalDateTime
@Nullable public static LocalDateTime createLocalDateTime(@Nullable GregorianCalendar aCal)
-
createLocalDateTime
@Nonnull public static LocalDateTime createLocalDateTime(long nMillis)
-
createLocalDateTime
@Nullable public static LocalDateTime createLocalDateTime(@Nullable Number aMillis)
-
getCurrentLocalDate
@Nonnegative public static LocalDate getCurrentLocalDate()
-
createLocalDate
@Nonnull public static LocalDate createLocalDate(int nYear, @Nonnull Month eMonth, int nDayOfMonth)
-
createLocalDate
@Nullable public static LocalDate createLocalDate(@Nullable GregorianCalendar aCalendar)
-
createLocalDate
@Nullable public static LocalDate createLocalDate(@Nullable LocalDateTime aLDT)
-
getCurrentLocalTime
@Nonnegative public static LocalTime getCurrentLocalTime()
-
getWithMillisOnly
@Nullable public static LocalTime getWithMillisOnly(@Nullable LocalTime aLT)
Get the passed time but with micro and nanoseconds set to 0, so that only the milliseconds part is present. This is helpful for XSD serialization, where only milliseconds granularity is available.- Parameters:
aLT- Source time. May benull.- Returns:
nullif the parameter isnull, the local time with microseconds and nanoseconds set to 0 otherwise.- Since:
- 9.4.7
-
getCurrentLocalTimeMillisOnly
@Nonnegative public static LocalTime getCurrentLocalTimeMillisOnly()
- Returns:
- The current local time but with micro and nanoseconds set to 0, so that only the milliseconds part is present. This is helpful for XSD serialization, where only milliseconds granularity is available.
- Since:
- 9.4.7
-
createLocalTime
@Nullable public static LocalTime createLocalTime(@Nullable GregorianCalendar aCalendar)
-
createLocalTime
@Nullable public static LocalTime createLocalTime(@Nullable LocalDateTime aLDT)
-
createLocalTime
@Nonnull public static LocalTime createLocalTime(int nHour, int nMinute, int nSecond)
-
createDate
@Nullable public static Date createDate(@Nullable ZonedDateTime aZDT)
-
createDate
@Nullable public static Date createDate(@Nullable OffsetDateTime aODT)
-
createDate
@Nullable public static Date createDate(@Nullable LocalDateTime aLDT)
-
createDateForDate
@Nonnull public static Date createDateForDate(int nYear, @Nonnull Month eMonth, int nDayOfMonth)
-
createGregorianCalendar
@Nonnull public static GregorianCalendar createGregorianCalendar()
-
createGregorianCalendarUTC
@Nonnull public static GregorianCalendar createGregorianCalendarUTC()
-
getCurrentYear
@Nonnegative public static int getCurrentYear()
-
getCurrentMonth
@Nonnegative public static int getCurrentMonth()
-
getCurrentDayOfMonth
@Nonnegative public static int getCurrentDayOfMonth()
-
getCurrentYearMonth
@Nonnegative public static YearMonth getCurrentYearMonth()
-
getCurrentInstant
@Nonnegative public static Instant getCurrentInstant()
-
getCurrentMillis
public static long getCurrentMillis()
-
getMillis
public static long getMillis(@Nonnull LocalDateTime aLDT)
-
getMillis
public static long getMillis(@Nonnull OffsetDateTime aODT)
-
getMillis
public static long getMillis(@Nonnull ZonedDateTime aZDT)
-
-