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

Was this helpful?

  1. Scripting
  2. Static Classes

LocalDateTimeUtil

PreviousGeneralDateUtilNextLocalDateUtil

Was this helpful?

This class provides utility methods for working with objects. It includes methods for formatting, parsing, and extracting various date and time components.

Methods

formatted(date: LocalDateTime): String

  • Returns a default formatted string using the workflow's default formatting.

  • Parameters:

    • date (type: LocalDateTime) - The LocalDateTime object to format.

  • Returns:

    • A string representation of the formatted LocalDateTime.

var formattedDate = LocalDateTimeUtil.formatted(LocalDateTime.now());

format(date: LocalDateTime, format: String): String

  • Formats a LocalDateTime object using a custom date and time format pattern.

  • Parameters:

    • date (type: LocalDateTime) - The LocalDateTime object to format.

    • format (type: String) - The custom date and time format pattern. Follows the pattern format from SimpleDateFormat for Java.

  • Returns:

    • A string representation of the formatted LocalDateTime based on the specified format pattern.

var customFormattedDate = LocalDateTimeUtil.format(LocalDateTime.now(),
                                "yyyy-MM-dd HH:mm:ss");

parse(dateStr: String, format: String): LocalDateTime

  • Parses a date string using a custom format and returns a LocalDateTime object.

  • Parameters:

    • dateStr (type: String) - The date string to parse.

    • format (type: String) - The custom date and time format pattern used for parsing.

  • Returns:

    • A LocalDateTime object representing the parsed date and time.

var parsedDate = LocalDateTimeUtil.parse("2023-11-07 15:30:00", 
                                "yyyy-MM-dd HH:mm:ss");

getYear(date: LocalDateTime): Integer

  • Retrieves the year component of a LocalDateTime.

  • Parameters:

    • date (type: LocalDateTime) - The LocalDateTime object from which to extract the year.

  • Returns:

    • An integer representing the year component.

var year = LocalDateTimeUtil.getYear(LocalDateTime.now()); // returns 2023

getDayOfYear(date: LocalDateTime): Integer

  • Retrieves the day of the year component of a LocalDateTime.

  • Parameters:

    • date (type: LocalDateTime) - The LocalDateTime object from which to extract the day of the year.

  • Returns:

    • An integer representing the day of the year.

var dayOfYear = LocalDateTimeUtil.getDayOfYear(LocalDateTime.now()); 

getMonthName(date: LocalDateTime): String

  • Retrieves the name of the month for a LocalDateTime.

  • Parameters:

    • date (type: LocalDateTime) - The LocalDateTime object from which to extract the month name.

  • Returns:

    • A string representing the name of the month.

var monthName = LocalDateTimeUtil.getMonthName(LocalDateTime.now());
// returns "NOVEMBER"

getMonth(date: LocalDateTime): Integer

  • Retrieves the month component of a LocalDateTime.

  • Parameters:

    • date (type: LocalDateTime) - The LocalDateTime object from which to extract the month.

  • Returns:

    • An integer representing the month.

var month = LocalDateTimeUtil.getMonth(LocalDateTime.now());

getDayOfWeek(date: LocalDateTime): String

  • Retrieves the day of the week for a LocalDateTime.

  • Parameters:

    • date (type: LocalDateTime) - The LocalDateTime object from which to extract the day of the week.

  • Returns:

    • A string representing the day of the week.

var dayOfWeek = LocalDateTimeUtil.getDayOfWeek(LocalDateTime.now());
// returns "TUESDAY"

getDayOfMonth(date: LocalDateTime): Integer

  • Retrieves the day of the month component of a LocalDateTime.

  • Parameters:

    • date (type: LocalDateTime) - The LocalDateTime object from which to extract the day of the month.

  • Returns:

    • An integer representing the day of the month.

var dayOfMonth = LocalDateTimeUtil.getDayOfMonth(LocalDateTime.now());

getHour(date: LocalDateTime): Integer

  • Retrieves the hour component of a LocalDateTime.

  • Parameters:

    • date (type: LocalDateTime) - The LocalDateTime object from which to extract the hour.

  • Returns:

    • An integer representing the hour.

var hour = LocalDateTimeUtil.getHour(LocalDateTime.now());

getMinute(date: LocalDateTime): Integer

  • Retrieves the minute component of a LocalDateTime.

  • Parameters:

    • date (type: LocalDateTime) - The LocalDateTime object from which to extract the minute.

  • Returns:

    • An integer representing the minute.

var minute = LocalDateTimeUtil.getMinute(LocalDateTime.now());

getSecond(date: LocalDateTime): Integer

  • Retrieves the second component of a LocalDateTime.

  • Parameters:

    • date (type: LocalDateTime) - The LocalDateTime object from which to extract the second.

  • Returns:

    • An integer representing the second.

var second = LocalDateTimeUtil.getSecond(LocalDateTime.now());

getNano(date: LocalDateTime): Integer

  • Retrieves the nanosecond component of a LocalDateTime.

  • Parameters:

    • date (type: LocalDateTime) - The LocalDateTime object from which to extract the nanosecond.

  • Returns:

    • An integer representing the nanosecond.

var nano = LocalDateTimeUtil.getNano(LocalDateTime.now());

These methods provide various operations to work with LocalDateTime objects, including formatting, parsing, and extracting individual date and time components.

LocalDateTime