Package net.bluemind.core.api.date
Class BmDateTimeWrapper
java.lang.Object
net.bluemind.core.api.date.BmDateTimeWrapper
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Test ifBmDateTime.timezone
is not null and is a valid identifier according toZoneId.getAvailableZoneIds()
copy
(long timestamp) Create a new BmDateTime usingBmDateTime.timezone
,BmDateTime.precision
and timestamp.static BmDateTime
Creates a BmDateTime based on a string.static BmDateTime
Creates a BmDateTime based on a string and a timezone.static BmDateTime
create
(String iso8601, String timezone, BmDateTime.Precision precision) Creates a BmDateTime based on a string, a timezone and a precision.static BmDateTime
create
(String iso8601, BmDateTime.Precision precision) Creates a BmDateTime based on a string and a precision.static BmDateTime
create
(LocalDateTime localDateTime, BmDateTime.Precision precision) Timezone will be set to UTC.static BmDateTime
create
(ZonedDateTime dateTime, BmDateTime.Precision precision) Timezone will be set afterZonedDateTime.getZone()
.Output the BmDateTime using the specified format pattern.static BmDateTime
fromTimestamp
(long timestamp) Creates a BmDateTime based on a timestamp.static BmDateTime
fromTimestamp
(long timestamp, String timezone) Creates a BmDateTime based on a timestamp and a timezone.static BmDateTime
fromTimestamp
(long timestamp, String timezone, BmDateTime.Precision precision) Creates a BmDateTime based on a timestamp, a timezone and a precision.boolean
isAfter
(BmDateTime date) boolean
isBefore
(BmDateTime date) toDate()
ConvertBmDateTime
to aDate
.transform theBmDateTime
instance to anZonedDateTime
}.toDateTime
(String timezone) transform theBmDateTime
instance to anZonedDateTime
static String
long
toTimestamp
(String timezone) IfBmDateTime
is a representation of aLocalDate
or aLocalDateTime
, timezone is used asBmDateTime.iso8601
tzstatic long
toTimestamp
(String iso8601, String timezone) Gets the milliseconds of theBmDateTime
from the Java epoch of 1970-01-01T00:00:00Z.long
ConvertBmDateTime.iso8601
to a timestamp.withTimeZone
(String timezone) ConvertBmDateTime
from 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.DateTime
and precision isBmDateTime.Precision.Date
: time will be stripped from iso8601 - iso8601 is a
BmDateTime.Precision.Date
and precision isBmDateTime.Precision.DateTime
: time will be set to 00:00:00 at timezone offset
- Parameters:
iso8601
- Iso8601 representation of aZonedDateTime
,LocalDate
,LocalDateTime
timezone
-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.Date
orBmDateTime.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
,LocalDateTime
precision
-BmDateTime.Precision.Date
orBmDateTime.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
,LocalDateTime
timezone
-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.Date
orBmDateTime.Precision.DateTime
- See Also:
-
create
Timezone will be set to UTC.- Parameters:
localDateTime
-precision
-BmDateTime.Precision.Date
orBmDateTime.Precision.DateTime
- See Also:
-
copy
Create a new BmDateTime usingBmDateTime.timezone
,BmDateTime.precision
and timestamp.- Parameters:
timestamp
-- See Also:
-
fromTimestamp
Creates a BmDateTime based on a timestamp. timezone is set toUTC
and precision toBmDateTime.Precision.DateTime
- Parameters:
timestamp
-- See Also:
-
fromTimestamp
Creates a BmDateTime based on a timestamp and a timezone. precision toBmDateTime.Precision.DateTime
- Parameters:
timestamp
-timezone
-- See Also:
-
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
ConvertBmDateTime
from 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
Output the BmDateTime using the specified format pattern.- Parameters:
pattern
- the pattern specification, null means usetoString
- Returns:
- the formatted string, not null
-
toIso8601
-
toIso8601
-
toDateTime
transform theBmDateTime
instance 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
ZonedDateTime
corresponding to theBmDateTime
-
toDateTime
transform theBmDateTime
instance to anZonedDateTime
}. Uses the timezone GMT as fallback.- Returns:
- the
ZonedDateTime
corresponding to theBmDateTime
-
isBefore
-
isAfter
-
containsTimeZone
public boolean containsTimeZone()Test ifBmDateTime.timezone
is not null and is a valid identifier according toZoneId.getAvailableZoneIds()
- Returns:
- True if
BmDateTime.timezone
is valid
-
toTimestamp
IfBmDateTime
is a representation of aLocalDate
or aLocalDateTime
, timezone is used asBmDateTime.iso8601
tz- Parameters:
timezone
-- Returns:
- Gets the milliseconds of the
BmDateTime
from the Java epoch - See Also:
-
toUTCTimestamp
public long toUTCTimestamp()ConvertBmDateTime.iso8601
to a timestamp. IfBmDateTime
is aLocalDate
or aLocalDateTime
, UTC timezone will be used.- Returns:
- Gets the milliseconds of the
BmDateTime
from the Java epoch. - See Also:
-
toTimestamp
Gets the milliseconds of theBmDateTime
from the Java epoch of 1970-01-01T00:00:00Z. IfBmDateTime
is aLocalDate
or aLocalDateTime
, timezone is used for the timestamp offset. Otherwise it is ignored.- Parameters:
iso8601
- Iso8601 representation of aZonedDateTime
,LocalDate
,LocalDateTime
timezone
-ZoneId.getId()
for ZonedDateTime. If the timezone is not recognized, the UTC timezone will be used.
-
toDate
ConvertBmDateTime
to aDate
. IfBmDateTime
is aLocalDate
or aLocalDateTime
, UTC timezone will be used.- See Also:
-