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

LocalDate

LocalDate Class

The LocalDate class represents a date (year, month, and day) without a time or time zone. It provides methods for creating, manipulating, and comparing date values.

var localdate = LocalDate.of(2023, 10, 24); // LDATE 2023-10-24

Static Methods

now()

  • Returns the current date.

  • Example Usage:

    var currentDate = LocalDate.now();

parse(text: String)

  • Parses the input text to create a LocalDate instance.

  • Example Usage:

    var parsedDate = LocalDate.parse("2023-10-24");

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

  • Creates a LocalDate instance with the specified year, month, and day values.

  • Example Usage:

    var customDate = LocalDate.of(2023, 10, 24);

ofYearDay(year: Integer, dayOfYear: Integer)

  • Creates a LocalDate instance based on the year and day of the year.

  • Example Usage:

    var dateFromYearDay = LocalDate.ofYearDay(2023, 100);

ofEpochDay(epochDay: Long)

  • Creates a LocalDate instance based on the number of days since the epoch (January 1, 1970).

  • Example Usage:

    var dateFromEpochDay = LocalDate.ofEpochDay(18898);

Getter Methods

getYear()

  • Gets the year field.

  • Returns the year as an int value.

  • Example Usage:

    var year = customDate.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 = customDate.getMonthValue();

getDayOfMonth()

  • Gets the day-of-month field.

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

  • Example Usage:

    var dayOfMonth = customDate.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 = customDate.getDayOfYear();

Date Manipulation Methods

minusYears(yearsToSubtract: Long)

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

  • Example Usage:

    var newDate = customDate.minusYears(1);

minusMonths(monthsToSubtract: Long)

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

  • Example Usage:

    var newDate = customDate.minusMonths(2);

minusWeeks(weeksToSubtract: Long)

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

  • Example Usage:

    var newDate = customDate.minusWeeks(3);

minusDays(daysToSubtract: Long)

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

  • Example Usage:

    var newDate = customDate.minusDays(10);

plusDays(daysToAdd: Long)

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

  • Example Usage:

    var newDate = customDate.plusDays(5);

daysUntil(endDate: LocalDate)

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

  • Example Usage:

    var daysUntil = customDate.daysUntil(endDate);

monthsUntil(endDate: LocalDate)

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

  • Example Usage:

    var monthsUntil = customDate.monthsUntil(endDate);

toEpochDay()

  • Returns the number of days since the epoch (typically January 1, 1970).

  • Example Usage:

    var epochDay = customDate.toEpochDay();

Comparison Methods

isBefore(other: LocalDate)

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

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

  • Example Usage:

    var isBefore = customDate.isBefore(parsedDate);

isAfter(other: LocalDate)

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

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

  • Example Usage:

    var isAfter = customDate.isAfter(parsedDate);

Date-Time Combination Methods

atStartOfDay()

  • Combines the date with the time of midnight to create a LocalDateTime at the start of the date.

  • Example Usage:

    var startOfDay = customDate.atStartOfDay();

atTime(time: LocalTime)

  • Combines the date with the specified LocalTime to create a LocalDateTime.

  • Example Usage:

    var dateTime = customDate.atTime(LocalTime.of(15, 30));

atTime(hour: Integer, minute: Integer, second: Integer)

  • Combines the date with the specified hour, minute, and second to create a LocalDateTime.

  • Example Usage:

    var dateTime = customDate.atTime(15, 30, 45);
PreviousLocalDateTimeNextLocalTime

Last updated 1 year ago