Home Reference Source

Function

Static Public Summary
public

convert(temporal: LocalDate | LocalDateTime | ZonedDateTime, zone: ZoneId): ToNativeJsConverter

converts a LocalDate, LocalDateTime or ZonedDateTime to a native Javascript Date.

public

nativeJs(date: Date | moment, zone: ZoneId): ZonedDateTime

Creates ZonedDateTime from a javascript Date or a moment instance.

Static Public

public convert(temporal: LocalDate | LocalDateTime | ZonedDateTime, zone: ZoneId): ToNativeJsConverter source

converts a LocalDate, LocalDateTime or ZonedDateTime to a native Javascript Date.

In a first step the temporal is converted to an Instant by adding implicit values.

A LocalDate is implicit set to a LocalDateTime at start of day. A LocalDateTime is implicit set to a ZonedDateTime with the passed zone or if null, with the system default time zone. A ZonedDateTime is converted to an Instant, if a zone is specified the zonedDateTime is adjusted to this zone, keeping the same Instant.

In a second step the instant is converted to a native Javascript Date

default zone for LocalDate and LocalDateTime is ZoneId.systemDefault().

Params:

NameTypeAttributeDescription
temporal LocalDate | LocalDateTime | ZonedDateTime
  • nullable: false

a joda temporal instance

zone ZoneId
  • optional

the zone of the temporal

Return:

ToNativeJsConverter

Example:

convert(localDate).toDate() // returns a javascript Date
convert(localDate).toEpochMilli()   // returns the epochMillis

public nativeJs(date: Date | moment, zone: ZoneId): ZonedDateTime source

Creates ZonedDateTime from a javascript Date or a moment instance.

Params:

NameTypeAttributeDescription
date Date | moment
  • nullable: false

a javascript Date or a moment instance

zone ZoneId
  • optional
  • default: ZoneId.systemDefault()

the zone of the returned ZonedDateTime, defaults to ZoneId.systemDefault()

Return:

ZonedDateTime