> For the complete documentation index, see [llms.txt](https://docs.b2winsuite.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.b2winsuite.com/scripting/types-and-objects/objects/period.md).

# Period

The `Period` class is designed to represent a time-based duration, typically measured in seconds and nanoseconds. It offers a range of static methods for creating durations based on days, hours, minutes, seconds, milliseconds, and nanoseconds. Additionally, it provides conversion methods to express the duration in various units, as well as the ability to calculate the duration between two temporal objects. This class is ideal for measuring time spans, tracking elapsed time, and performing time-based calculations in applications.

### Static Methods

#### `ofDays(days: Integer)`

* Obtains a `Period` representing a number of standard 24-hour days.
* Example Usage:

  ```java
  var daysPeriod = Period.ofDays(5);
  ```

#### `ofMonths(months: Integer)`

* Obtains a `Period`representing a number of standard months.
* Example Usage:

  ```java
  var monthsPeriod = Period.ofMonths(12);
  ```

#### `ofYears(years: Integer)`

* Obtains a `Period`representing a number of standard years.
* Example Usage:

  ```java
  var yearsPeriod = Period.ofYears(30);
  ```

#### `ofWeeks(weeks: Long)`

* Obtains a `Period`representing a number of weeks.
* Example Usage:

  ```java
  var weeksPeriod = Period.ofWeeks(4);
  ```

#### `parse(text: String)`

* Obtains a `Period`from a text string such as `P2Y3M4D`.
* Parses a textual representation of a period.
* Example Usage:

  ```java
  var parsedPeriod = Period.parse("P2Y3M4D");
  ```

#### `between(startInclusive: LocalDate, endExclusive: LocalDate)`

* Obtains a `Period`representing the duration between two temporal objects.
* Example Usage:

  ```java
  var end = LocalDate.now(); // current date-time
  var start = end.minusDays(1); // current date-time minus 1 day
  var duration = Period.between(start, end); // period is 1 day
  ```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.b2winsuite.com/scripting/types-and-objects/objects/period.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
