public final class DateAdapter extends Object
Constructor and Description |
---|
DateAdapter()
Creates a date adapter without any options.
|
DateAdapter(DateAdapterOptions options)
Creates a date adapter using the options passed as argument.
|
Modifier and Type | Method and Description |
---|---|
Date |
add(Date time,
long amount,
TimeUnit unit)
Adds the specified amount of unit to the given date.
|
Date |
add(long time,
long amount,
TimeUnit unit)
Adds the specified amount of unit to the given timestamp.
|
double |
diff(Date maxTime,
Date minTime,
TimeUnit unit)
Returns the number of unit between the given dates.
|
double |
diff(long maxTime,
long minTime,
TimeUnit unit)
Returns the number of unit between the given timestamps.
|
Date |
endOf(Date time,
TimeUnit unit)
Returns end of unit for the given date.
|
Date |
endOf(long time,
TimeUnit unit)
Returns end of unit for the given timestamp.
|
String |
format(Date time,
String format)
Returns the formatted date in the specified format for a given date.
|
String |
format(Date time,
TimeUnit unit)
Returns the formatted date in the specified format for a given date, using the default format related to time unit.
|
String |
format(long time,
String format)
Returns the formatted date in the specified format for a given timestamp.
|
String |
format(long time,
TimeUnit unit)
Returns the formatted date in the specified format for a given timestamp, using the default format related to time unit.
|
DateAdapterFormats |
getFormats()
Returns the provided default formats.
|
String |
getId()
Returns the date adapter id.
|
DateAdapterOptions |
getOptions()
Returns the options used to configure the date adapter.
|
Date |
parse(String time,
String format)
Parses the given value and return the associated date.
|
Date |
startOf(Date time,
IsoWeekDay weekday)
Returns the start by weekday for the given date.
|
Date |
startOf(Date time,
TimeUnit unit)
Returns the start of unit for the given date.
|
Date |
startOf(long time,
IsoWeekDay weekday)
Returns the start by weekday for the given timestamp.
|
Date |
startOf(long time,
TimeUnit unit)
Returns the start of unit for the given timestamp.
|
public DateAdapter()
public DateAdapter(DateAdapterOptions options)
options
- date adapter optionspublic String getId()
public DateAdapterFormats getFormats()
public DateAdapterOptions getOptions()
public Date parse(String time, String format)
time
- the value to parse (usually comes from the data)format
- the expected data formatnull
public String format(long time, String format)
time
- the timestamp to formatformat
- the date/time tokenpublic String format(long time, TimeUnit unit)
time
- the timestamp to formatunit
- the time unit to usepublic String format(Date time, String format)
time
- the date to formatformat
- the date/time tokenpublic String format(Date time, TimeUnit unit)
time
- the date to formatunit
- the time unit instancepublic Date add(long time, long amount, TimeUnit unit)
time
- the input timestampamount
- the amount to addunit
- the time unit instancepublic Date add(Date time, long amount, TimeUnit unit)
time
- the input dateamount
- the amount to addunit
- the time unit instancepublic double diff(long maxTime, long minTime, TimeUnit unit)
maxTime
- the input timestamp (reference)minTime
- the timestamp to subtractunit
- the time unit instancepublic double diff(Date maxTime, Date minTime, TimeUnit unit)
maxTime
- the input date (reference)minTime
- the date to subtractunit
- the time unit instancepublic Date startOf(long time, TimeUnit unit)
time
- the input timestampunit
- the time unit instancepublic Date startOf(Date time, TimeUnit unit)
time
- the input dateunit
- the time unit instancepublic Date startOf(long time, IsoWeekDay weekday)
time
- the input timestampweekday
- the ISO day of the week (only needed if parameter "unit" is isoWeek).public Date startOf(Date time, IsoWeekDay weekday)
time
- the input dateweekday
- the ISO day of the week (only needed if parameter "unit" is isoWeek).public Date endOf(long time, TimeUnit unit)
time
- the input timestampunit
- the time unit instance