Package org.apache.commons.lang3.time
Class CalendarUtils
java.lang.Object
org.apache.commons.lang3.time.CalendarUtils
Helps use 
Calendars.- Since:
- 3.10
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final CalendarUtilsThe singleton instance forCalendar.getInstance().
- 
Constructor SummaryConstructorsConstructorDescriptionCalendarUtils(Calendar calendar) Creates an instance for the given Calendar.
- 
Method SummaryModifier and TypeMethodDescriptionintGets the current day of month.intGets the current day of year.static CalendarUtilsCreates a new instance based on the current time in the default time zone with the defaultLocale.Category.FORMATlocale.intgetMonth()Gets the current month.intgetYear()Gets the current year.Converts this instance to aLocalDateTime.static LocalDateTimetoLocalDateTime(Calendar calendar) Converts a Calendar to a LocalDateTime.Converts this instance to aOffsetDateTime.static OffsetDateTimetoOffsetDateTime(Calendar calendar) Converts a Calendar to a OffsetDateTime.Converts this instance to aZonedDateTime.static ZonedDateTimetoZonedDateTime(Calendar calendar) Converts a Calendar to a ZonedDateTime.
- 
Field Details- 
INSTANCEThe singleton instance forCalendar.getInstance(). The instance is created when the class is initialized and is based on the current time in the default time zone with the defaultLocale.Category.FORMATlocale.- See Also:
 
 
- 
- 
Constructor Details- 
CalendarUtilsCreates an instance for the given Calendar.- Parameters:
- calendar- A Calendar.
 
 
- 
- 
Method Details- 
getInstanceCreates a new instance based on the current time in the default time zone with the defaultLocale.Category.FORMATlocale.- Returns:
- a new instance.
- Since:
- 3.14.0
 
- 
toLocalDateTimeConverts a Calendar to a LocalDateTime.- Parameters:
- calendar- the Calendar to convert.
- Returns:
- a LocalDateTime.
- Since:
- 3.17.0
 
- 
toOffsetDateTimeConverts a Calendar to a OffsetDateTime.- Parameters:
- calendar- the Calendar to convert.
- Returns:
- a OffsetDateTime.
- Since:
- 3.17.0
 
- 
toZonedDateTimeConverts a Calendar to a ZonedDateTime.- Parameters:
- calendar- the Calendar to convert.
- Returns:
- a ZonedDateTime.
- Since:
- 3.17.0
 
- 
getDayOfMonthGets the current day of month.- Returns:
- the current day of month.
 
- 
getDayOfYearGets the current day of year.- Returns:
- the current day of year.
- Since:
- 3.13.0
 
- 
getMonthGets the current month.- Returns:
- the current month.
 
- 
getYearGets the current year.- Returns:
- the current year.
 
- 
toLocalDateTimeConverts this instance to aLocalDateTime.- Returns:
- a LocalDateTime.
- Since:
- 3.17.0
 
- 
toOffsetDateTimeConverts this instance to aOffsetDateTime.- Returns:
- a OffsetDateTime.
- Since:
- 3.17.0
 
- 
toZonedDateTimeConverts this instance to aZonedDateTime.- Returns:
- a ZonedDateTime.
- Since:
- 3.17.0
 
 
-