CalendarUtils

public class org.apache.commons.lang3.time.CalendarUtils[source]

Helps use Calendars.

Since:

3.10

Constructors

CalendarUtils(Calendar)

Creates an instance for the given Calendar.

public CalendarUtils(Calendar calendar)[source]

Creates an instance for the given Calendar.

Parameters:

calendar – A Calendar.

Fields and constants

INSTANCE

The singleton instance for Calendar#getInstance().

public static final CalendarUtils INSTANCE[source]

The singleton instance for Calendar#getInstance(). The instance is created when the class is initialized and is based on the current time in the default time zone with the default Category#FORMAT locale.

See also:

CalendarUtils#getInstance()

Methods

getDayOfMonth()

Gets the current day of month.

getDayOfYear()

Gets the current day of year.

getInstance()

Gets a new instance based on the current time in the default time zone with the default Category#FORMAT locale.

getMonth()

Gets the current month.

getYear()

Gets the current year.

toLocalDate()

Converts this instance to a LocalDate.

toLocalDateTime()

Converts this instance to a LocalDateTime.

toLocalDateTime(Calendar)

Converts a Calendar to a LocalDateTime.

toOffsetDateTime()

Converts this instance to a OffsetDateTime.

toOffsetDateTime(Calendar)

Converts a Calendar to an OffsetDateTime.

toZonedDateTime()

Converts this instance to a ZonedDateTime.

toZonedDateTime(Calendar)

Converts a Calendar to a ZonedDateTime.

public int getDayOfMonth()[source]

Gets the current day of month.

Returns:

The current day of month.

public int getDayOfYear()[source]

Gets the current day of year.

Returns:

The current day of year.

Since:

3.13.0

public static CalendarUtils getInstance()[source]

Gets a new instance based on the current time in the default time zone with the default Category#FORMAT locale.

Returns:

A new instance.

Since:

3.14.0

public int getMonth()[source]

Gets the current month.

Returns:

The current month.

public int getYear()[source]

Gets the current year.

Returns:

The current year.

public LocalDate toLocalDate()[source]

Converts this instance to a LocalDate.

Returns:

A LocalDate.

Since:

3.18.0

public LocalDateTime toLocalDateTime()[source]

Converts this instance to a LocalDateTime.

Returns:

A LocalDateTime.

Since:

3.17.0

public static LocalDateTime toLocalDateTime(Calendar calendar)[source]

Converts a Calendar to a LocalDateTime.

Parameters:

calendar – The Calendar to convert.

Returns:

A LocalDateTime.

Since:

3.17.0

public OffsetDateTime toOffsetDateTime()[source]

Converts this instance to a OffsetDateTime.

Returns:

A OffsetDateTime.

Since:

3.17.0

public static OffsetDateTime toOffsetDateTime(Calendar calendar)[source]

Converts a Calendar to an OffsetDateTime.

Parameters:

calendar – The Calendar to convert.

Returns:

A OffsetDateTime.

Since:

3.17.0

public ZonedDateTime toZonedDateTime()[source]

Converts this instance to a ZonedDateTime.

Returns:

A ZonedDateTime.

Since:

3.17.0

public static ZonedDateTime toZonedDateTime(Calendar calendar)[source]

Converts a Calendar to a ZonedDateTime.

Parameters:

calendar – The Calendar to convert.

Returns:

A ZonedDateTime.

Since:

3.17.0