public class JodaTimeUtils
extends java.lang.Object
JodaTime.| Modifier and Type | Field and Description |
|---|---|
static org.joda.time.DateTime |
BEGINNING_OF_TIME
This represents a time before all (representable) times.
|
static long |
BEGINNING_OF_TIME_LONG
This represents a time before all (representable) times, in long representation.
|
static org.joda.time.DateTime |
ENDING_OF_TIME
This represents a time after all (representable) times.
|
static long |
ENDING_OF_TIME_LONG
This represents a time after all (representable) times, in long representation.
|
static org.joda.time.DateTimeZone |
EST
EST
|
static org.joda.time.DateTimeZone |
GMT
GMT
|
static org.joda.time.DateTime |
ORIGIN
This is the reference time "origin": 1970 January 1, midnight, UTC.
|
| Modifier and Type | Method and Description |
|---|---|
static org.joda.time.DateTime |
getDate(int year,
int month,
int day,
org.joda.time.DateTimeZone tz)
Construct a
DateTime instance with year, month, day, and time zone. |
static org.joda.time.DateTime |
getDateTime(java.lang.String str)
Construct a
DateTime instance from a string which ends in TimeZone specification. |
static org.joda.time.DateTime |
getDateTime(java.lang.String str,
java.text.DateFormat format,
org.joda.time.DateTimeZone tz)
Construct a
DateTime instance from a string with no TimeZone specified. |
static org.joda.time.DateTime |
getLastDayOfMonth(org.joda.time.DateTime t)
Get the last day of the month which contain a time.
|
static org.joda.time.DateTime |
getLastMillisecondOfDay(org.joda.time.DateTime t)
Get the last millisecond the day which contain a time.
|
static int |
getNumberOfPeriodsBetween(org.joda.time.DateTime t1,
org.joda.time.DateTime t2,
org.joda.time.Period period)
Return the number of periods between two times, rounding up.
|
static boolean |
isWeekend(org.joda.time.DateTime time)
Check if the given time is a weekend.
|
static java.util.List<org.joda.time.DateTime> |
makePeriodicInstants(org.joda.time.DateTime startTime,
org.joda.time.Period period,
int nPeriods)
Make a list of periodic time instants.
|
static org.joda.time.DateTime |
max(org.joda.time.DateTime t1,
org.joda.time.DateTime t2)
Return the later of two
DateTime instances. |
static org.joda.time.DateTime |
min(org.joda.time.DateTime t1,
org.joda.time.DateTime t2)
Return the earlier of two
DateTime instances. |
static org.joda.time.DateTime |
minusWeekdayPeriod(org.joda.time.DateTime time,
org.joda.time.Period period)
Subtract a weekday-period (i.e., skipping weekends) from a
DateTime. |
static org.joda.time.DateTime |
nextWeekDay(org.joda.time.DateTime time)
Get the next weekday, i.e., skipping Saturdays and Sundays.
|
static org.joda.time.DateTime |
plusWeekdayPeriod(org.joda.time.DateTime time,
org.joda.time.Period period)
Add a weekday-period (i.e., skipping weekends) to a
DateTime. |
static org.joda.time.DateTime |
previousWeekDay(org.joda.time.DateTime time)
Get the previous weekday, i.e., skipping Saturdays and Sundays.
|
public static final org.joda.time.DateTimeZone GMT
public static final org.joda.time.DateTimeZone EST
public static final org.joda.time.DateTime ORIGIN
public static final org.joda.time.DateTime BEGINNING_OF_TIME
public static final long BEGINNING_OF_TIME_LONG
public static final org.joda.time.DateTime ENDING_OF_TIME
public static final long ENDING_OF_TIME_LONG
public static org.joda.time.DateTime getDate(int year,
int month,
int day,
org.joda.time.DateTimeZone tz)
DateTime instance with year, month, day, and time zone. It is set to mid-night.year - yearmonth - month of the yearday - day of the monthtz - time zonepublic static org.joda.time.DateTime getDateTime(java.lang.String str)
throws java.text.ParseException
DateTime instance from a string which ends in TimeZone specification.str - the date-time stringDateTime representationjava.text.ParseException - if there is an error parsing the stringpublic static org.joda.time.DateTime getDateTime(java.lang.String str,
java.text.DateFormat format,
org.joda.time.DateTimeZone tz)
throws java.text.ParseException
DateTime instance from a string with no TimeZone specified.str - the date-time stringformat - the formattertz - the time zone; null if default time zoneDateTime representationjava.text.ParseException - if there is an error parsing the stringpublic static org.joda.time.DateTime nextWeekDay(org.joda.time.DateTime time)
time - a DateTimepublic static org.joda.time.DateTime previousWeekDay(org.joda.time.DateTime time)
time - a DateTimepublic static org.joda.time.DateTime plusWeekdayPeriod(org.joda.time.DateTime time,
org.joda.time.Period period)
DateTime.
For example, adding a weekday-period of 2 days and 4 hours to a time
instant representing Thursday 5pm results in a time instant at next
Monday 9pm.time - the original time instantperiod - the period to be addedDateTime after the period addedpublic static org.joda.time.DateTime minusWeekdayPeriod(org.joda.time.DateTime time,
org.joda.time.Period period)
DateTime.
For example, subtracting a weekday-period of 2 days and 4 hours from a
time instant representing Monday 9pm results in a time instant at
previous Thursday 5pm.time - the original time instantperiod - the period to be addedDateTime after the period subtractedpublic static boolean isWeekend(org.joda.time.DateTime time)
time - a timetrue if the given time is a weekendpublic static org.joda.time.DateTime min(org.joda.time.DateTime t1,
org.joda.time.DateTime t2)
DateTime instances.t1 - time 1t2 - time 2t1 and t2public static org.joda.time.DateTime max(org.joda.time.DateTime t1,
org.joda.time.DateTime t2)
DateTime instances.t1 - time 1t2 - time 2t1 and t2public static int getNumberOfPeriodsBetween(org.joda.time.DateTime t1,
org.joda.time.DateTime t2,
org.joda.time.Period period)
t1 - time 1t2 - time 2period - a durationpublic static java.util.List<org.joda.time.DateTime> makePeriodicInstants(org.joda.time.DateTime startTime,
org.joda.time.Period period,
int nPeriods)
startTime - start timeperiod - the periodnPeriods - the number of instants, excluding start timepublic static org.joda.time.DateTime getLastDayOfMonth(org.joda.time.DateTime t)
t - a timet is inpublic static org.joda.time.DateTime getLastMillisecondOfDay(org.joda.time.DateTime t)
t - a timet is in