> For the complete documentation index, see [llms.txt](https://www.pranaypourkar.co.in/the-programmers-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pranaypourkar.co.in/the-programmers-guide/java/java-basics/java-data-types/others/enum/pre-defined-enum.md).

# Pre-Defined Enum

Overview of built-in Enum provided in Java.

## About

A **Predefined Enum** refers to an enum that is commonly used or provided by a library or framework (such as Java's own standard enums). These enums provide frequently-used constants, such as `TimeUnit` or `DayOfWeek` in Java, that offer built-in methods and functionality based on the type.

## Examples of Predefined Enums in Java

### java.time.temporal.ChronoUnit

It is an enum in the `java.time.temporal` package in Java, introduced in Java 8 as part of the `java.time` package for date and time manipulation. It represents units of time, such as days, hours, minutes, seconds, etc., and provides a way to perform date and time arithmetic. `ChronoUnit` constants can be used along with methods like `plus` and `minus` to add or subtract a specified amount of time from a date-time object.

Here are some commonly used `ChronoUnit` constants:

> * `NANOS`: Nanoseconds
> * `MICROS`: Microseconds
> * `MILLIS`: Milliseconds
> * `SECONDS`: Seconds
> * `MINUTES`: Minutes
> * `HOURS`: Hours
> * `DAYS`: Days
> * `WEEKS`: Weeks
> * `MONTHS`: Months
> * `YEARS`: Years
> * `DECADES`: Decades
> * `CENTURIES`: Centuries
> * `MILLENNIA`: Millennia
> * `ERAS`: Eras

```java
ZonedDateTime currentDateTime = ZonedDateTime.now();
ZonedDateTime futureDateTime = currentDateTime.plus(3, ChronoUnit.HOURS);
ZonedDateTime pastDateTime = currentDateTime.minus(1, ChronoUnit.DAYS);
```

### java.util.concurrent.TimeUnit

Used for specifying time durations in multithreaded code.

Constants include `NANOSECONDS`, `MICROSECONDS`, `MILLISECONDS`, `SECONDS`, `MINUTES`, `HOURS`, and `DAYS`.

```java
long duration = TimeUnit.SECONDS.toMillis(10); // Converts 10 seconds to milliseconds
```

### java.time.DayOfWeek

Part of the `java.time` package, this enum represents days of the week.

Constants include `MONDAY`, `TUESDAY`, `WEDNESDAY`, etc.

Built-in methods like `.plus(int days)` make it easy to calculate future or past days.

```java
DayOfWeek today = DayOfWeek.MONDAY;
DayOfWeek tomorrow = today.plus(1); // Returns TUESDAY
```

### java.nio.file.StandardOpenOption

Provides options for file operations, such as `READ`, `WRITE`, `APPEND`, and `CREATE`.

These options are used in file I/O to specify how the file should be handled.

```java
Files.write(path, data, StandardOpenOption.APPEND);
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.pranaypourkar.co.in/the-programmers-guide/java/java-basics/java-data-types/others/enum/pre-defined-enum.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
