| Modifier and Type | Field and Description |
|---|---|
static CalendarUtils |
INSTANCE
The singleton instance for
Calendar.getInstance(). |
| Constructor and Description |
|---|
CalendarUtils(Calendar calendar)
Creates an instance for the given Calendar.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getDayOfMonth()
Gets the current day of month.
|
int |
getDayOfYear()
Gets the current day of year.
|
static CalendarUtils |
getInstance()
Creates a new instance based on the current time in the default time zone with the default
Locale.Category.FORMAT locale. |
int |
getMonth()
Gets the current month.
|
int |
getYear()
Gets the current year.
|
LocalDate |
toLocalDate()
Converts this instance to a
LocalDate. |
LocalDateTime |
toLocalDateTime()
Converts this instance to a
LocalDateTime. |
static LocalDateTime |
toLocalDateTime(Calendar calendar)
Converts a Calendar to a LocalDateTime.
|
OffsetDateTime |
toOffsetDateTime()
Converts this instance to a
OffsetDateTime. |
static OffsetDateTime |
toOffsetDateTime(Calendar calendar)
Converts a Calendar to a OffsetDateTime.
|
ZonedDateTime |
toZonedDateTime()
Converts this instance to a
ZonedDateTime. |
static ZonedDateTime |
toZonedDateTime(Calendar calendar)
Converts a Calendar to a ZonedDateTime.
|
public static final CalendarUtils INSTANCE
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 Locale.Category.FORMAT locale.getInstance()public CalendarUtils(Calendar calendar)
calendar - A Calendar.public static CalendarUtils getInstance()
Locale.Category.FORMAT locale.public static LocalDateTime toLocalDateTime(Calendar calendar)
calendar - the Calendar to convert.public static OffsetDateTime toOffsetDateTime(Calendar calendar)
calendar - the Calendar to convert.public static ZonedDateTime toZonedDateTime(Calendar calendar)
calendar - the Calendar to convert.public int getDayOfMonth()
public int getDayOfYear()
public int getMonth()
public int getYear()
public LocalDate toLocalDate()
LocalDate.public LocalDateTime toLocalDateTime()
LocalDateTime.public OffsetDateTime toOffsetDateTime()
OffsetDateTime.public ZonedDateTime toZonedDateTime()
ZonedDateTime.Copyright © 2001–2025 The Apache Software Foundation. All rights reserved.