Class BmDateTimeWrapper
java.lang.Object
net.bluemind.core.api.date.BmDateTimeWrapper
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanTest ifBmDateTime.timezoneis not null and is a valid identifier according toZoneId.getAvailableZoneIds()copy(long timestamp) Create a new BmDateTime usingBmDateTime.timezone,BmDateTime.precisionand timestamp.static BmDateTimeCreates a BmDateTime based on a string.static BmDateTimeCreates a BmDateTime based on a string and a timezone.static BmDateTimecreate(String iso8601, String timezone, BmDateTime.Precision precision) Creates a BmDateTime based on a string, a timezone and a precision.static BmDateTimecreate(String iso8601, BmDateTime.Precision precision) Creates a BmDateTime based on a string and a precision.static BmDateTimeCreate a new BmDateTime from a LocalDatestatic BmDateTimecreate(LocalDateTime localDateTime, BmDateTime.Precision precision) Timezone will be set to UTC.static BmDateTimecreate(ZonedDateTime dateTime, BmDateTime.Precision precision) Timezone will be set afterZonedDateTime.getZone().Output the BmDateTime using the specified format pattern.static BmDateTimefromTimestamp(long timestamp) Creates a BmDateTime based on a timestamp.static BmDateTimefromTimestamp(long timestamp, String timezone) Creates a BmDateTime based on a timestamp and a timezone.static BmDateTimefromTimestamp(long timestamp, String timezone, BmDateTime.Precision precision) Creates a BmDateTime based on a timestamp, a timezone and a precision.booleanisAfter(BmDateTime date) booleanisBefore(BmDateTime date) minus(TemporalAmount duration) plus(TemporalAmount duration) static booleansameRecurId(BmDateTime a, BmDateTime b) Compares two recurids for occurrence identity.toDate()ConvertBmDateTimeto aDate.transform theBmDateTimeinstance to anZonedDateTime}.toDateTime(String timezone) transform theBmDateTimeinstance to anZonedDateTimestatic StringlongtoTimestamp(String timezone) IfBmDateTimeis a representation of aLocalDateor aLocalDateTime, timezone is used asBmDateTime.iso8601tzstatic longtoTimestamp(String iso8601, String timezone) Gets the milliseconds of theBmDateTimefrom the Java epoch of 1970-01-01T00:00:00Z.longConvertBmDateTime.iso8601to a timestamp.withTimeZone(String timezone) ConvertBmDateTimefrom bmDateTime.timezone to timezone.
-
Field Details
-
bmDateTime
-
-
Constructor Details
-
BmDateTimeWrapper
-
-
Method Details
-
create
Creates a BmDateTime based on a string, a timezone and a precision.- If precision is a
BmDateTime.Precision.Date, timezone parameter ignored and null will be used. - If timezone is null and precision is a
BmDateTime.Precision.DateTime, iso8601 timezone will be used. If there is no timezone in iso8601, null will be used.
- Either iso8601 and timezone contain a tz: iso8601 will be converted to timezone
- timezone do not contain a tz and iso8601 do: tz offset will be stripped from iso8601
- timezone do contain a tz and iso8601 do not: tz offset will be added to iso8601 without conversion
- iso8601 is a
BmDateTime.Precision.DateTimeand precision isBmDateTime.Precision.Date: time will be stripped from iso8601 - iso8601 is a
BmDateTime.Precision.Dateand precision isBmDateTime.Precision.DateTime: time will be set to 00:00:00 at timezone offset
- Parameters:
iso8601- Iso8601 representation of aZonedDateTime,LocalDate,LocalDateTimetimezone-ZoneId.getId()for ZonedDateTime, null for Local date or local datetime. If the timezone is not recognized, the timezone will be parsed from iso8601.precision-BmDateTime.Precision.DateorBmDateTime.Precision.DateTime
- If precision is a
-
create
Creates a BmDateTime based on a string and a precision. timezone is parsed from iso8601.- Parameters:
iso8601- Iso8601 representation of aZonedDateTime,LocalDate,LocalDateTimeprecision-BmDateTime.Precision.DateorBmDateTime.Precision.DateTime- See Also:
-
create
Creates a BmDateTime based on a string and a timezone. Precision is parsed from iso8601.- Parameters:
iso8601- Iso8601 representation of aZonedDateTime,LocalDate,LocalDateTimetimezone-ZoneId.getId()for ZonedDateTime, null for Local date or local datetime. If the timezone is not recognized, null will be used.- See Also:
-
create
Creates a BmDateTime based on a string. Precision and timezone are parsed from iso8601.- Parameters:
iso8601- Iso8601 representation of aZonedDateTime,LocalDate,LocalDateTime- See Also:
-
create
Timezone will be set afterZonedDateTime.getZone().- Parameters:
dateTime-precision-BmDateTime.Precision.DateorBmDateTime.Precision.DateTime- See Also:
-
create
Create a new BmDateTime from a LocalDate- Parameters:
date-
-
create
Timezone will be set to UTC.- Parameters:
localDateTime-precision-BmDateTime.Precision.DateorBmDateTime.Precision.DateTime- See Also:
-
copy
Create a new BmDateTime usingBmDateTime.timezone,BmDateTime.precisionand timestamp.- Parameters:
timestamp-- See Also:
-
fromTimestamp
Creates a BmDateTime based on a timestamp. timezone is set toUTCand precision toBmDateTime.Precision.DateTime- Parameters:
timestamp-
-
fromTimestamp
Creates a BmDateTime based on a timestamp and a timezone. precision toBmDateTime.Precision.DateTime- Parameters:
timestamp-timezone-
-
fromTimestamp
public static BmDateTime fromTimestamp(long timestamp, String timezone, BmDateTime.Precision precision) Creates a BmDateTime based on a timestamp, a timezone and a precision. timestamp will be print as iso8601 datetime. If timezone is null or timezone is invalid, the iso8601 string will be print with the UTC timezone.- Parameters:
timestamp- the milliseconds from 1970-01-01T00:00:00Ztimezone-ZoneId.getId()for ZonedDateTime, null for Local date or local datetime. If the timezone is not recognized UTC will be used.precision- If precision isBmDateTime.Precision.Date: No timezone nor time will be printed in the iso string- See Also:
-
withTimeZone
ConvertBmDateTimefrom bmDateTime.timezone to timezone. If bmDateTime.timezone is null timezone will be used without conversion. If bmDateTime.timezone is not null, bmDateTime will be converted to timezone.- Parameters:
timezone-ZoneId.getId()for ZonedDateTime, null for Local date or local datetime. If the timezone is not recognized, the default timezone ID will be used (UTC).
-
format
-
toIso8601
-
toIso8601
-
toDateTime
transform theBmDateTimeinstance to anZonedDateTime- Parameters:
timezone- a Fallback timezone which is used if either the instance is of precision Date, the instance contains no timezone or the timezone contained in the ISO8601 value is not valid- Returns:
- the
ZonedDateTimecorresponding to theBmDateTime
-
toDateTime
transform theBmDateTimeinstance to anZonedDateTime}. Uses the timezone GMT as fallback.- Returns:
- the
ZonedDateTimecorresponding to theBmDateTime
-
isBefore
-
isAfter
-
containsTimeZone
public boolean containsTimeZone()Test ifBmDateTime.timezoneis not null and is a valid identifier according toZoneId.getAvailableZoneIds()- Returns:
- True if
BmDateTime.timezoneis valid
-
toTimestamp
IfBmDateTimeis a representation of aLocalDateor aLocalDateTime, timezone is used asBmDateTime.iso8601tz- Parameters:
timezone-- Returns:
- Gets the milliseconds of the
BmDateTimefrom the Java epoch - See Also:
-
toUTCTimestamp
public long toUTCTimestamp()ConvertBmDateTime.iso8601to a timestamp. IfBmDateTimeis aLocalDateor aLocalDateTime, UTC timezone will be used.- Returns:
- Gets the milliseconds of the
BmDateTimefrom the Java epoch.
-
minus
-
plus
-
toTimestamp
Gets the milliseconds of theBmDateTimefrom the Java epoch of 1970-01-01T00:00:00Z. IfBmDateTimeis aLocalDateor aLocalDateTime, timezone is used for the timestamp offset. Otherwise it is ignored.- Parameters:
iso8601- Iso8601 representation of aZonedDateTime,LocalDate,LocalDateTimetimezone-ZoneId.getId()for ZonedDateTime. If the timezone is not recognized, the UTC timezone will be used.
-
toDate
ConvertBmDateTimeto aDate. IfBmDateTimeis aLocalDateor aLocalDateTime, UTC timezone will be used.- See Also:
-
sameRecurId
Compares two recurids for occurrence identity. The timezone label is not compared: it can legitimately differ between two representations of the same occurrence (a named timezone from DB deserialization, a numeric offset extracted from an x-bm-event email header, or no timezone at all for a UTC value), while the offset actually used to resolve the instant is always embedded inBmDateTime.iso8601. Comparing the resolved instant, astoUTCTimestamp()does, is therefore correct regardless of the timezone label on either side.
-