B2Win Suite Documentation (Under Construction)
5.4
5.4
  • B2Win Suite Documentation
  • Scripting
    • B2Win Suite Scripting Overview
    • Scripting in B2Data
      • Custom Script Nodes
        • Custom Script
        • Source Script Node (File)
        • Source Script Node (Table)
        • Source Script Node (Object)
        • If-Else Condition
        • Condition Node
      • In DataPrep
      • Properties
      • Workflow Applications
        • Workflow #1
        • Workflow #2
    • Getting Started
    • Language Basics
    • Types & Objects
      • Primitives
      • Objects
        • Instant
        • LocalDateTime
        • LocalDate
        • LocalTime
        • JsonNode
        • ObjectNode
        • File
        • SuiteTable
        • Duration
      • Arrays & Maps
      • Row, Column, StringColumn
    • Utilities
      • Date & Time
        • InstantUtil
        • GeneralDateUtil
        • LocalDateTimeUtil
        • LocalDateUtil
        • LocalTimeUtil
        • Formatting
        • Timezones
      • Math
      • StrictMath
      • NumericUtil
      • DbUtil
      • DbExecutor
      • StateUtil
      • FileUtil
      • JsonUtil
      • HttpUtil
      • NodeInputReader
      • RandomUtil
      • HashingUtil
      • CompressionUtil
      • Logging
    • Properties
    • Context and System
      • Context
      • System
    • Configurations
      • Workflow Configuration
    • Tutorial
    • Feedback
  • B2Data
    • Workflow Settings
      • General Settings
      • Global/All Properties
      • Execution Configuration
        • General
        • Runtime
        • Compiler
        • Storage
        • Clean Up
      • Permissions
    • Nodes
      • Scheduler
    • Services Configuration
      • Power BI
Powered by GitBook
On this page
  • Instant Class
  • Static Methods
  • Comparison Methods
  • Conversion Methods
  1. Scripting
  2. Types & Objects
  3. Objects

Instant

Instant Class

The Instant class is a fundamental component of B2Win Suite Scripting, allowing you to work with instants in time. This class provides methods for creating and manipulating time-related data.

Static Methods

  • Instant.now(): Instant

Description: Returns an instance representing the current instant.

Example:

var currentInstant = Instant.now();

  • Instant.parse(text: String)

Description: Parses a string and returns an instance of Instant.

Example:

var parsedInstant = Instant.parse("2023-10-20T12:00:00Z");

Comparison Methods

  • isBefore(otherInstant: Instant)

Description: Compares this Instant with another Instant and returns true if it is before the other instant or false otherwise.

Example:

var instantA = Instant.parse("2023-10-20T08:00:00Z"); // parse Instant A
var instantB = Instant.parse("2023-10-20T09:00:00Z"); // parse Instant B

var isBefore = instantA.isBefore(instantB);

if (isBefore) {
    // Do something when instantA is before instantB
    return "instantA is before instantB";
} else {
    // Do something when instantA is not before instantB
    return "instantA is not before instantB";
}

  • isAfter(otherInstant: Instant)

Description: Compares this Instant with another Instant and returns true if it is after the other instant or false otherwise.

Example:

var isAfter = instantA.isAfter(instantB);

if (isAfter) {
    // Do something when instantA is after instantB
    return "instantA is after instantB";
} else {
    // Do something when instantA is not after instantB
    return "instantA is not after instantB";
}

Conversion Methods

  • toEpochMilli()

Description: Converts this Instant to the number of milliseconds since the epoch (00:00:00 UTC on 1 January 1970) and returns the value in type Long.

Example:

var myInstant = Instant.parse("2023-10-20T08:00:00Z");
var epochMillis = myInstant.toEpochMilli();

  • toString()

Description: Converts this Instant to a string representation and returns it.

Example:

var myInstant = Instant.parse("2023-10-20T08:00:00Z");
var instantString = myInstant.toString();
PreviousObjectsNextLocalDateTime

Last updated 1 year ago