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
  • LocalDateTime Class
  • Static Methods
  • Getter Methods
  • Date Manipulation Methods
  • Comparison Methods
  • Date-Time Separation Methods
  1. Scripting
  2. Types & Objects
  3. Objects

LocalDateTime

LocalDateTime Class

The LocalDateTime class represents a date and time without a time zone. It combines a LocalDate and a LocalTime to represent a specific date and time of day.

var localdateTime = LocalDateTime.of(2023, 10, 24, 15, 30); 
// LDTIME 2023-10-24T15:30:00 

Static Methods

now(): LocalDateTime

  • Returns the current date and time.

var currentDateTime = LocalDateTime.now();

parse(text: String): LocalDateTime

  • Parses the input text to create a LocalDateTime instance.

var parsedDateTime = LocalDateTime.parse("2023-10-24T15:30:45");

of(year: Integer, month: Integer, dayOfMonth: Integer, hour: Integer, minute: Integer)

  • Creates a LocalDateTime instance with the specified year, month, day, hour, and minute values.

var customDateTime = LocalDateTime.of(2023, 10, 24, 15, 30);

Getter Methods

getYear(): Int

  • Gets the year field.

  • Returns the year as an int value.

  • Example Usage:

    var year = customDateTime.getYear();

getMonthValue()

  • Gets the month-of-year field from 1 to 12.

  • Returns the month as an int from 1 to 12.

  • Example Usage:

    var month = customDateTime.getMonthValue();

getDayOfMonth()

  • Gets the day-of-month field.

  • Returns the day-of-month as an int from 1 to 31.

  • Example Usage:

    var dayOfMonth = customDateTime.getDayOfMonth();

getDayOfYear()

  • Gets the day-of-year field.

  • Returns the day-of-year as an int from 1 to 365 (or 366 in a leap year).

  • Example Usage:

    var dayOfYear = customDateTime.getDayOfYear();

Date Manipulation Methods

minusYears(yearsToSubtract: Long)

  • Returns a new LocalDateTime with the specified number of years subtracted.

  • Example Usage:

    var newDateTime = customDateTime.minusYears(1);

minusMonths(monthsToSubtract: Long)

  • Returns a new LocalDateTime with the specified number of months subtracted.

  • Example Usage:

    var newDateTime = customDateTime.minusMonths(2);

minusWeeks(weeksToSubtract: Long)

  • Returns a new LocalDateTime with the specified number of weeks subtracted.

  • Example Usage:

    var newDateTime = customDateTime.minusWeeks(3);

minusDays(daysToSubtract: Long)

  • Returns a new LocalDateTime with the specified number of days subtracted.

  • Example Usage:

    var newDateTime = customDateTime.minusDays(10);

plusDays(daysToAdd: Long)

  • Returns a new LocalDateTime with the specified number of days added.

  • Example Usage:

    var newDateTime = customDateTime.plusDays(5);

daysUntil(endDateTime: LocalDateTime)

  • Calculates the number of days until the specified end date and time.

  • Example Usage:

    var daysUntil = customDateTime.daysUntil(endDateTime);

monthsUntil(endDateTime: LocalDateTime)

  • Calculates the number of months until the specified end date and time.

  • Example Usage:

    var monthsUntil = customDateTime.monthsUntil(endDateTime);

Comparison Methods

isBefore(other: LocalDateTime)

  • Checks if the current date and time is before the specified date and time.

  • Returns true if the current date and time is before other, false otherwise.

  • Example Usage:

    var isBefore = customDateTime.isBefore(parsedDateTime);

isAfter(other: LocalDateTime)

  • Checks if the current date and time is after the specified date and time.

  • Returns true if the current date and time is after other, false otherwise.

  • Example Usage:

    var isAfter = customDateTime.isAfter(parsedDateTime);

Date-Time Separation Methods

toLocalDate()

  • Gets the LocalDate part of this date-time.

  • Returns a LocalDate with the same year, month, and day as this date-time.

  • Example Usage:

    var datePart = customDateTime.toLocalDate();

toLocalTime()

  • Gets the LocalTime part of this date-time.

  • Returns a LocalTime with the same hour, minute, second, and nanosecond as this date-time.

  • Example Usage:

    var timePart = customDateTime.toLocalTime();
PreviousInstantNextLocalDate

Last updated 1 year ago