public class BmDateTimeWrapper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
BmDateTime |
bmDateTime |
Constructor and Description |
---|
BmDateTimeWrapper(BmDateTime bmDateTime) |
Modifier and Type | Method and Description |
---|---|
boolean |
containsTimeZone()
Test if
BmDateTime.timezone is not null and is a valid identifier
according to ZoneId.getAvailableZoneIds() |
BmDateTime |
copy(long timestamp)
Create a new BmDateTime using
BmDateTime.timezone ,
BmDateTime.precision and timestamp. |
static BmDateTime |
create(java.time.LocalDateTime localDateTime,
BmDateTime.Precision precision)
Timezone will be set to UTC.
|
static BmDateTime |
create(java.lang.String iso8601)
Creates a BmDateTime based on a string.
|
static BmDateTime |
create(java.lang.String iso8601,
BmDateTime.Precision precision)
Creates a BmDateTime based on a string and a precision.
|
static BmDateTime |
create(java.lang.String iso8601,
java.lang.String timezone)
Creates a BmDateTime based on a string and a timezone.
|
static BmDateTime |
create(java.lang.String iso8601,
java.lang.String timezone,
BmDateTime.Precision precision)
Creates a BmDateTime based on a string, a timezone and a precision.
|
static BmDateTime |
create(java.time.ZonedDateTime dateTime,
BmDateTime.Precision precision)
Timezone will be set after
ZonedDateTime.getZone() . |
java.lang.String |
format(java.lang.String format)
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,
java.lang.String timezone)
Creates a BmDateTime based on a timestamp and a timezone.
|
static BmDateTime |
fromTimestamp(long timestamp,
java.lang.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) |
java.util.Date |
toDate()
Convert
BmDateTime to a Date . |
java.time.ZonedDateTime |
toDateTime()
transform the
BmDateTime instance to an
ZonedDateTime }. |
java.time.ZonedDateTime |
toDateTime(java.lang.String timezone)
transform the
BmDateTime instance to an
ZonedDateTime |
java.lang.String |
toIso8601() |
static java.lang.String |
toIso8601(long timestamp,
java.lang.String timezone) |
long |
toTimestamp(java.lang.String timezone)
If
BmDateTime is a representation of a LocalDate or a
LocalDateTime , timezone is used as BmDateTime.iso8601 tz |
static long |
toTimestamp(java.lang.String iso8601,
java.lang.String timezone)
Gets the milliseconds of the
BmDateTime from the Java epoch of
1970-01-01T00:00:00Z. |
long |
toUTCTimestamp()
Convert
BmDateTime.iso8601 to a timestamp. |
BmDateTime |
withTimeZone(java.lang.String timezone)
Convert
BmDateTime from bmDateTime.timezone to timezone. |
public final BmDateTime bmDateTime
public BmDateTimeWrapper(BmDateTime bmDateTime)
public static BmDateTime create(java.lang.String iso8601, java.lang.String timezone, BmDateTime.Precision precision)
BmDateTime.Precision.Date
, timezone parameter ignored and
null will be used.BmDateTime.Precision.DateTime
,
iso8601 timezone will be used. If there is no timezone in iso8601, null will
be used.
BmDateTime.Precision.DateTime
and precision is
BmDateTime.Precision.Date
: time will be stripped from iso8601BmDateTime.Precision.Date
and precision is
BmDateTime.Precision.DateTime
: time will be set to 00:00:00 at timezone
offsetiso8601
- Iso8601 representation of a ZonedDateTime
,
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
or BmDateTime.Precision.DateTime
public static BmDateTime create(java.lang.String iso8601, BmDateTime.Precision precision)
iso8601
- Iso8601 representation of a ZonedDateTime
,
LocalDate
, LocalDateTime
precision
- BmDateTime.Precision.Date
or BmDateTime.Precision.DateTime
#create(String, String, Precision)
public static BmDateTime create(java.lang.String iso8601, java.lang.String timezone)
iso8601
- Iso8601 representation of a ZonedDateTime
,
LocalDate
, LocalDateTime
timezone
- ZoneId.getId()
for ZonedDateTime, null for Local date
or local datetime. If the timezone is not recognized, null
will be used.#create(String, String, Precision)
public static BmDateTime create(java.lang.String iso8601)
iso8601
- Iso8601 representation of a ZonedDateTime
,
LocalDate
, LocalDateTime
#create(String, String, Precision)
public static BmDateTime create(java.time.ZonedDateTime dateTime, BmDateTime.Precision precision)
ZonedDateTime.getZone()
.dateTime
- precision
- BmDateTime.Precision.Date
or BmDateTime.Precision.DateTime
#create(String, String, Precision)
public static BmDateTime create(java.time.LocalDateTime localDateTime, BmDateTime.Precision precision)
localDateTime
- precision
- BmDateTime.Precision.Date
or BmDateTime.Precision.DateTime
#create(String, String, Precision)
public BmDateTime copy(long timestamp)
BmDateTime.timezone
,
BmDateTime.precision
and timestamp.timestamp
- #fromTimestamp(long, String, Precision)
public static BmDateTime fromTimestamp(long timestamp)
UTC
and precision to
BmDateTime.Precision.DateTime
timestamp
- #create(long, String, Precision)
public static BmDateTime fromTimestamp(long timestamp, java.lang.String timezone)
BmDateTime.Precision.DateTime
timestamp
- timezone
- #create(long, String, Precision)
public static BmDateTime fromTimestamp(long timestamp, java.lang.String timezone, BmDateTime.Precision precision)
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 is BmDateTime.Precision.Date
: No timezone nor
time will be printed in the iso string#create(String, String, Precision)
public BmDateTime withTimeZone(java.lang.String timezone)
BmDateTime
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.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).public java.lang.String format(java.lang.String format)
pattern
- the pattern specification, null means use
toString
public java.lang.String toIso8601()
public static java.lang.String toIso8601(long timestamp, java.lang.String timezone)
public java.time.ZonedDateTime toDateTime(java.lang.String timezone)
BmDateTime
instance to an
ZonedDateTime
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 validZonedDateTime
corresponding to the
BmDateTime
public java.time.ZonedDateTime toDateTime()
BmDateTime
instance to an
ZonedDateTime
}. Uses the timezone GMT as fallback.ZonedDateTime
corresponding to the
BmDateTime
public boolean isBefore(BmDateTime date)
public boolean isAfter(BmDateTime date)
public boolean containsTimeZone()
BmDateTime.timezone
is not null and is a valid identifier
according to ZoneId.getAvailableZoneIds()
BmDateTime.timezone
is validpublic long toTimestamp(java.lang.String timezone)
BmDateTime
is a representation of a LocalDate
or a
LocalDateTime
, timezone is used as BmDateTime.iso8601
tztimezone
- BmDateTime
from the Java epochtoTimestamp(String, String)
public long toUTCTimestamp()
BmDateTime.iso8601
to a timestamp. If BmDateTime
is a
LocalDate
or a LocalDateTime
, UTC timezone will be used.BmDateTime
from the Java epoch.BmDateTimeWrapper#toTimeZonedTimestamp(String, String)
public static long toTimestamp(java.lang.String iso8601, java.lang.String timezone)
BmDateTime
from the Java epoch of
1970-01-01T00:00:00Z. If BmDateTime
is a LocalDate
or a
LocalDateTime
, timezone is used for the timestamp offset. Otherwise
it is ignored.iso8601
- Iso8601 representation of a ZonedDateTime
,
LocalDate
, LocalDateTime
timezone
- ZoneId.getId()
for ZonedDateTime. If the timezone is
not recognized, the UTC timezone will be used.public java.util.Date toDate()
BmDateTime
to a Date
. If BmDateTime
is a
LocalDate
or a LocalDateTime
, UTC timezone will be used.toUTCTimestamp()
Copyright © 2021. All Rights Reserved.