B2Win Suite Documentation (Under Construction)
ContactB2Data
5.2
5.2
  • 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
    • Data Types and Data Structures
      • Primitive Data Types
      • Data Structures
      • SuiteTable
      • Row, Column, StringColumn
    • Non-static Classes
      • Instant Class
      • LocalDateTime
      • LocalDate
      • LocalTime
      • JsonNode Class
      • File Class
    • Static Classes
      • Duration Class
      • Math Class
      • StrictMath Class
      • InstantUtil
      • NumericUtil
      • GeneralDateUtil
      • LocalDateTimeUtil
      • LocalDateUtil
      • LocalTimeUtil
      • DbUtil
      • StateUtil
      • FileUtil
      • JsonUtil
      • HttpUtil
      • NodeInputReader
      • RandomUtil
    • Property Class
    • Context and System
      • Context Class
      • System Class
    • Logging and Configuration
      • Logging
      • Configuration
    • Tutorial
    • Feedback
Powered by GitBook
On this page
  • Instant Class
  • Static Methods
  • Comparison Methods
  • Conversion Methods

Was this helpful?

  1. Scripting
  2. Non-static Classes

Instant Class

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();
PreviousNon-static ClassesNextLocalDateTime

Was this helpful?