# LocalDateUtil

`LocalDateUtil` provides utility methods for working with `LocalDate` objects. It includes methods for parsing, and extracting various date components.

### Methods

**`parseDate(dateStr: String, format: String): LocalDate`**

* Parses a date string using a custom format and returns a `LocalDate` object.
* Parameters:
  * `dateStr` (type: String) - The date string to parse.
  * `format` (type: String) - The custom date format pattern used for parsing.
* Returns:
  * A `LocalDate` object representing the parsed date.

```typescript
var dateStr = "2023-11-07";
var format = "yyyy-MM-dd";
var parsedDate = LocalDateUtil.parseDate(dateStr, format);
```

**`formatDate(date: LocalDate, format: String): LocalDate`**

* Parses a date Formats a LocalDate object as a string using the specified format.
* Parameters:
  * `date` (type: LocalDate) - The LocalDate object to be formatted.
  * `format` (type: String) - The custom date format pattern used for formatting.
* Returns:
  * A `String` representing the formatted date.

```typescript
var dateTime = LocalDateTime.now();
var format = "yyyy-MM-dd";
var formattedDate = LocalDateUtil.formatDate(dateTime, format);
```

**`getYear(date: LocalDateTime): Integer`**

* Retrieves the year component of a `LocalDateTime` object.
* Parameters:
  * `date` (type: LocalDateTime) - The `LocalDateTime` object from which to extract the year.
* Returns:
  * An integer representing the year component.

```typescript
var dateTime = LocalDateTime.now();
var year = LocalDateUtil.getYear(dateTime);
```

**`getDayOfYear(date: LocalDate): Integer`**

* Retrieves the day of the year component of a `LocalDate` object.
* Parameters:
  * `date` (type: LocalDate) - The `LocalDate` object from which to extract the day of the year.
* Returns:
  * An integer representing the day of the year.

```typescript
var date = LocalDate.now();
var dayOfYear = LocalDateUtil.getDayOfYear(date);
```

**`getMonthName(date: LocalDate): String`**

* Retrieves the name of the month for a `LocalDate` object.
* Parameters:
  * `date` (type: LocalDate) - The `LocalDate` object from which to extract the month name.
* Returns:
  * A string representing the name of the month.

```typescript
var date = LocalDate.now();
var monthName = LocalDateUtil.getMonthName(date);
```

**`getMonth(date: LocalDate): Integer`**

* Retrieves the month component of a `LocalDate` object.
* Parameters:
  * `date` (type: LocalDate) - The `LocalDate` object from which to extract the month.
* Returns:
  * An integer representing the month.

```typescript
var date = LocalDate.now();
var month = LocalDateUtil.getMonth(date);
```

**`getDayOfWeek(date: LocalDate): String`**

* Retrieves the day of the week for a `LocalDate` object.
* Parameters:
  * `date` (type: LocalDate) - The `LocalDate` object from which to extract the day of the week.
* Returns:
  * A string representing the day of the week.

```typescript
var customDate = LocalDate.of(2023, 10, 24);
return LocalDateUtil.getDayOfWeek(customDate); // TUESDAY
```

**`getDayOfMonth(date: LocalDate): Integer`**

* Retrieves the day of the month component of a `LocalDate` object.
* Parameters:
  * `date` (type: LocalDate) - The `LocalDate` object from which to extract the day of the month.
* Returns:
  * An integer representing the day of the month.

```typescript
var date = LocalDate.now();
var dayOfMonth = LocalDateUtil.getDayOfMonth(date);
```

**`getWeekOfYear(date: LocalDate): Integer`**

* Get the week number of the year for a given date.
* Parameters:
  * `date` (type: LocalDate) - The `LocalDate` object to get the week number for..
* Returns:
  * The week number of the year as an Integer.

```typescript
var date = LocalDate.now();
LocalDateUtil.getWeekOfYear(date);
```

**`getDateOfWeek(year: Integer, week: Integer, dayOfWeek: DayOfWeek): Integer`**

* Returns the date of the week for the given year and week number.
* Parameters:
  * `year` - The year for which to get the start date of the week.
  * `week` - The week number for which to get the start date.
  * `dayOfWeek` - The day of the week for which to get the date.
* Returns:
  * The start date of the specified week in the specified year.

```typescript
var date = LocalDate.now();
var dayOfMonth = LocalDateUtil.getDateOfWeek(2025, 28, DayOfWeek.SUNDAY);
```

These methods provide various operations to work with `LocalDate` objects, including parsing date strings, and extracting individual date components.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.b2winsuite.com/scripting/utilities/date-and-time/localdateutil.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
