Bluestep JS Documentation
    Preparing search index...

    Class Time

    This is an implementation of Java Time. See the docs for java.time (SE 11). If you don't like java.time, feel free to import a JavaScript library to use.

    Ways to get the current time:

    B.optUser.ifPresent(user => user.time.now());
    B.time.Instant().now();
    B.time.Clock().system().now();
    Index

    Constructors

    Properties

    B6P_LOCAL_DATE: DateTimeFormatter

    Convenience property. Same as calling B.time.DateTimeFormatter.ofPattern("uuuu/MM/dd")

    B6P_LOCAL_DATETIME: DateTimeFormatter

    Convenience property. Same as calling B.time.DateTimeFormatter.ofPattern("uuuu/MM/dd hh:mm:ss a")

    B6P_LOCAL_TIME: DateTimeFormatter

    Convenience property. Same as calling B.time.DateTimeFormatter.ofPattern("hh:mm:ss a")

    Calendar: typeof Calendar

    This is deprecated and should only be used when required.

    ChronoUnit: typeof ChronoUnit
    Clock: typeof Clock

    Java doc: java.time.Clock

    DateTimeFormatter: typeof DateTimeFormatter
    DateTimeFormatterBuilder: typeof DateTimeFormatterBuilder
    DayOfWeek: typeof DayOfWeek
    Duration: typeof Duration
    Instant: typeof Instant
    LocalDate: typeof LocalDate
    LocalDateTime: typeof LocalDateTime
    LocalTime: typeof LocalTime
    Month: typeof Month

    Java doc: java.time.Month

    MonthDay: typeof MonthDay
    OffsetDateTime: typeof OffsetDateTime
    OffsetTime: typeof OffsetTime
    Period: typeof Period

    Java doc: java.time.Period

    TemporalAdjusters: typeof TemporalAdjusters
    TimeZone: typeof TimeZone

    This is deprecated and should only be used when required.

    ValueRange: typeof ValueRange
    Year: typeof Year

    Java doc: java.time.Year

    YearMonth: typeof YearMonth
    ZonedDateTime: typeof ZonedDateTime
    ZoneId: typeof ZoneId

    Java doc: java.time.ZoneId

    ZoneOffset: typeof ZoneOffset

    Methods

    • Adds a value to a calendar field and returns the new field value.

      Parameters

      • cal: Calendar
      • calendarField: number

        The Calendar field constant (e.g. Calendar.YEAR)

      • amount: number

      Returns number

    • Adds a value to a field of a ZonedDateTime and returns the modified ZonedDateTime.

      Parameters

      • zdt: ZonedDateTime
      • calendarField: number

        The Calendar field constant

      • amount: number

      Returns ZonedDateTime

    • Adds a value to a field of a LocalDate and returns the modified LocalDate.

      Parameters

      • ld: LocalDate
      • calendarField: number

        The Calendar field constant

      • amount: number

      Returns LocalDate

    • Adds a value to a field of a LocalTime and returns the modified LocalTime.

      Parameters

      • lt: LocalTime
      • calendarField: number

        The Calendar field constant

      • amount: number

      Returns LocalTime

    • Alters the input according to the string passed

      Parameters

      Returns ZonedDateTime

    • Alters the input according to the string passed

      Parameters

      Returns LocalDate

    • Alters the input according to the string passed

      Parameters

      Returns LocalTime

    • Creates a new [[Java.Time.Date]]

      Parameters

      • Optionaltime: number

        epoc milliseconds

      Returns Date

    • Divides a DateDiff by a number (uses total milliseconds).

      Parameters

      Returns DateDiff

    • Creates a DateDiff from a millisecond value.

      Parameters

      • millis: number

      Returns DateDiff

    • Creates a DateDiff from a string representation.

      Parameters

      • diffStr: string

      Returns DateDiff

    • Multiplies a DateDiff by a floating-point number (uses total milliseconds).

      Parameters

      Returns DateDiff

    • Multiplies a DateDiff by an integer, preserving individual component fields (years, months, days, etc.).

      Parameters

      Returns DateDiff

    • Negates a DateDiff (flips its sign).

      Parameters

      Returns DateDiff

    • Formats a legacy Calendar as a string using a SimpleDateFormat pattern.

      Parameters

      • cal: Calendar
      • formatStr: string

        SimpleDateFormat pattern (e.g. "MM/dd/yyyy")

      Returns string

    • Formats a temporal as a string using a DateTimeFormatter pattern.

      Parameters

      Returns string

    • Formats an elapsed time in milliseconds as a human-readable string.

      Parameters

      • millis: number
      • abbreviated: boolean

        true for short labels (e.g. "2h 3m"), false for full labels (e.g. "2 hours 3 minutes")

      Returns string

    • Creates a [[Java.Time.Date]] object given an [[Java.Time.Instant]]

      Parameters

      Returns Date

    • Returns the day of the month from a legacy Calendar object.

      Parameters

      Returns number

    • Returns the day of the month from a date or datetime.

      Parameters

      Returns number

    • Returns the day of the week from a legacy Calendar object (1=Sunday, 7=Saturday).

      Parameters

      Returns number

    • Returns the day of the week (1=Sunday, 7=Saturday) from a date or datetime.

      Parameters

      Returns number

    • Returns the ordinal day-of-week within the month from a legacy Calendar object.

      Parameters

      Returns number

    • Returns the ordinal day-of-week within the month from a date or datetime.

      Parameters

      Returns number

    • Returns the day of the year from a legacy Calendar object.

      Parameters

      Returns number

    • Returns the day of the year from a date or datetime.

      Parameters

      Returns number

    • Returns the 12-hour clock hour from a legacy Calendar object.

      Parameters

      Returns number

    • Returns the 12-hour clock hour from a time or datetime.

      Parameters

      Returns number

    • Returns the 24-hour clock hour from a legacy Calendar object.

      Parameters

      Returns number

    • Returns the 24-hour clock hour from a time or datetime.

      Parameters

      Returns number

    • Returns true if the legacy Calendar object is in the AM period.

      Parameters

      Returns boolean

    • Returns true if the time or datetime is in the AM period.

      Parameters

      Returns boolean

    • Returns the millisecond from a legacy Calendar object.

      Parameters

      Returns number

    • Returns the millisecond from a time or datetime.

      Parameters

      Returns number

    • Returns the minute from a legacy Calendar object.

      Parameters

      Returns number

    • Returns the minute from a time or datetime.

      Parameters

      Returns number

    • Returns the month (0-based) from a legacy Calendar object.

      Parameters

      Returns number

    • Returns the month (0-based, 0=January) from a date or datetime.

      Parameters

      Returns number

    • Returns the second from a legacy Calendar object.

      Parameters

      Returns number

    • Returns the second from a time or datetime.

      Parameters

      Returns number

    • Returns the time in milliseconds since epoch from a legacy Calendar object.

      Parameters

      Returns number

    • Returns the time in milliseconds since epoch.

      Parameters

      Returns number

    • Returns the time zone ID string from a legacy Calendar object.

      Parameters

      Returns string

    • Returns the time zone ID string from a ZonedDateTime.

      Parameters

      Returns string

    • Returns the week of the month from a legacy Calendar object.

      Parameters

      Returns number

    • Returns the week of the month from a date or datetime.

      Parameters

      Returns number

    • Returns the week of the year from a legacy Calendar object.

      Parameters

      Returns number

    • Returns the week of the year from a date or datetime.

      Parameters

      Returns number

    • Returns the year from a legacy Calendar object.

      Parameters

      Returns number

    • Returns the year from a date or datetime.

      Parameters

      Returns number

    • Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds.

      Returns number

    • Returns the current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds. This method can only be used to measure elapsed time and is not related to any other notion of system or wall-clock time. The value returned represents nanoseconds since some fixed but arbitrary origin time (perhaps in the future, so values may be negative). The same origin is used by all invocations of this method in an instance of a Java virtual machine; other virtual machine instances are likely to use a different origin. This method provides nanosecond precision, but not necessarily nanosecond resolution (that is, how frequently the value changes) - no guarantees are made except that the resolution is at least as good as that of currentTimeMillis(). Differences in successive calls that span greater than approximately 292 years (263 nanoseconds) will not correctly compute elapsed time due to numerical overflow. The values returned by this method become meaningful only when the difference between two such values, obtained within the same instance of a Java virtual machine, is computed. For example, to measure how long some code takes to execute: long startTime = B.time.nanos(); // ... the code being measured ... long elapsedNanos = B.time.nanos() - startTime; To compare elapsed time against a timeout, use if (B.time.nanos() - startTime >= timeoutNanos) ... instead of if (B.time.nanos() >= startTime + timeoutNanos) ... because of the possibility of numerical overflow.

      Returns number

    • Alters the input according to the string passed

      Parameters

      Returns ZonedDateTime

    • Alters the input according to the string passed

      Parameters

      Returns LocalDate

    • Alters the input according to the string passed

      Parameters

      Returns LocalTime

    • Sets the day of the month on a legacy Calendar object.

      Parameters

      Returns void

    • Returns a new ZonedDateTime with the day of month set.

      Parameters

      Returns ZonedDateTime

    • Returns a new LocalDate with the day of month set.

      Parameters

      Returns LocalDate

    • Sets the day of the week on a legacy Calendar object (1=Sunday, 7=Saturday).

      Parameters

      Returns void

    • Returns a new ZonedDateTime with the day of week set (1=Sunday, 7=Saturday).

      Parameters

      Returns ZonedDateTime

    • Returns a new LocalDate with the day of week set (1=Sunday, 7=Saturday).

      Parameters

      Returns LocalDate

    • Sets the ordinal day-of-week within the month on a legacy Calendar object.

      Parameters

      Returns void

    • Sets the day of the year on a legacy Calendar object.

      Parameters

      Returns void

    • Returns a new ZonedDateTime with the day of year set.

      Parameters

      Returns ZonedDateTime

    • Returns a new LocalDate with the day of year set.

      Parameters

      Returns LocalDate

    • Sets the 12-hour clock hour on a legacy Calendar object.

      Parameters

      Returns void

    • Returns a new ZonedDateTime with the 12-hour clock hour set.

      Parameters

      Returns ZonedDateTime

    • Returns a new LocalTime with the 12-hour clock hour set.

      Parameters

      Returns LocalTime

    • Sets the 24-hour clock hour on a legacy Calendar object.

      Parameters

      Returns void

    • Returns a new ZonedDateTime with the 24-hour clock hour set.

      Parameters

      Returns ZonedDateTime

    • Returns a new LocalTime with the 24-hour clock hour set.

      Parameters

      Returns LocalTime

    • Sets the AM/PM flag on a legacy Calendar object.

      Parameters

      • cal: Calendar
      • value: boolean

        true for AM, false for PM

      Returns void

    • Returns a new ZonedDateTime with AM/PM set.

      Parameters

      Returns ZonedDateTime

    • Returns a new LocalTime with AM/PM set.

      Parameters

      • lt: LocalTime
      • isAM: boolean

        true for AM, false for PM

      Returns LocalTime

    • Sets the millisecond on a legacy Calendar object.

      Parameters

      Returns void

    • Returns a new ZonedDateTime with the millisecond set.

      Parameters

      Returns ZonedDateTime

    • Returns a new LocalTime with the millisecond set.

      Parameters

      Returns LocalTime

    • Sets the minute on a legacy Calendar object.

      Parameters

      Returns void

    • Returns a new ZonedDateTime with the minute set.

      Parameters

      Returns ZonedDateTime

    • Returns a new LocalTime with the minute set.

      Parameters

      Returns LocalTime

    • Sets the month (0-based) on a legacy Calendar object.

      Parameters

      Returns void

    • Returns a new ZonedDateTime with the month set (0-based, 0=January).

      Parameters

      Returns ZonedDateTime

    • Returns a new LocalDate with the month set (0-based, 0=January).

      Parameters

      Returns LocalDate

    • Sets the second on a legacy Calendar object.

      Parameters

      Returns void

    • Returns a new ZonedDateTime with the second set.

      Parameters

      Returns ZonedDateTime

    • Returns a new LocalTime with the second set.

      Parameters

      Returns LocalTime

    • Sets the time in milliseconds since epoch on a legacy Calendar object.

      Parameters

      Returns void

    • Returns a new ZonedDateTime with the epoch millis set.

      Parameters

      Returns ZonedDateTime

    • Sets the time zone on a legacy Calendar object.

      Parameters

      • cal: Calendar
      • zoneId: string

        Time zone ID (e.g. "America/New_York")

      Returns void

    • Returns a new ZonedDateTime with the time zone set.

      Parameters

      Returns ZonedDateTime

    • Sets the week of the month on a legacy Calendar object.

      Parameters

      Returns void

    • Sets the week of the year on a legacy Calendar object.

      Parameters

      Returns void

    • Sets the year on a legacy Calendar object.

      Parameters

      Returns void

    • Returns a new ZonedDateTime with the year set.

      Parameters

      Returns ZonedDateTime

    • Returns a new LocalDate with the year set.

      Parameters

      Returns LocalDate

    • Parses a date string into a legacy Calendar using a SimpleDateFormat pattern. Default format: MM/dd/yyyy.

      Parameters

      • dateStr: string
      • OptionalformatStr: string

        SimpleDateFormat pattern

      Returns Calendar

    • Parses a date/time string into a legacy Calendar using a SimpleDateFormat pattern. Default format: MM/dd/yyyy h:mma.

      Parameters

      • dateStr: string
      • OptionalformatStr: string

        SimpleDateFormat pattern

      • OptionaltimeZoneId: string

        Time zone ID (e.g. "America/New_York")

      Returns Calendar

    • Parses a date string into a LocalDate using a DateTimeFormatter pattern. Default format: MM/dd/yyyy.

      Parameters

      • dateStr: string
      • OptionalformatStr: string

      Returns LocalDate

    • Parses a time string into a LocalTime using a DateTimeFormatter pattern. Default format: h:mma.

      Parameters

      • dateStr: string
      • OptionalformatStr: string

      Returns LocalTime

    • Parses a time string into a legacy Calendar using a SimpleDateFormat pattern. Default format: h:mma.

      Parameters

      • dateStr: string
      • OptionalformatStr: string

        SimpleDateFormat pattern

      Returns Calendar

    • Parses a date/time string into a ZonedDateTime using a DateTimeFormatter pattern. Default format: MM/dd/yyyy h:mma.

      Parameters

      • dateStr: string
      • OptionalformatStr: string
      • OptionaltimeZoneId: string

      Returns ZonedDateTime

    • Return the user's ZoneId or the Systems ZoneId if there is no user.

      Returns ZoneId