public final class DateUtil extends Object
Modifier and Type | Field | Description |
---|---|---|
static long |
CALENDAR_YEAR |
One calendar year: 365.2425 days (31556952000 milliseconds).
|
static long |
DAY |
One day: 24 hours (86 400 000 milliseconds).
|
static long |
HOUR |
One hour: 60 minutes (3 600 000 milliseconds).
|
static long |
MINUTE |
One minute: 60 seconds (60 000 milliseconds).
|
static long |
SECOND |
One second: 1000 milliseconds.
|
Modifier and Type | Method | Description |
---|---|---|
static long |
currentTimeDay() |
Gets the current time, rounded down to the closest day.
|
static long |
currentTimeHour() |
Gets the current time, rounded down to the closest hour.
|
static long |
currentTimeMinute() |
Gets the current time, rounded down to the closest minute.
|
static long |
currentTimeSecond() |
Gets the current time, rounded down to the closest second.
|
static long |
delta(long pStart) |
Returns the time between the given start time and now (as defined by
System.currentTimeMillis() ). |
static long |
delta(Date pStart) |
Returns the time between the given start time and now (as defined by
System.currentTimeMillis() ). |
static long |
roundToDay(long pTime) |
Rounds the given time down to the closest day, using the default timezone.
|
static long |
roundToDay(long pTime,
TimeZone pTimeZone) |
Rounds the given time down to the closest day, using the given timezone.
|
static long |
roundToHour(long pTime) |
Rounds the given time down to the closest hour, using the default timezone.
|
static long |
roundToHour(long pTime,
TimeZone pTimeZone) |
Rounds the given time down to the closest hour, using the given timezone.
|
static long |
roundToMinute(long pTime) |
Rounds the given time down to the closest minute.
|
static long |
roundToSecond(long pTime) |
Rounds the given time down to the closest second.
|
public static final long SECOND
public static final long MINUTE
public static final long HOUR
public static final long DAY
public static final long CALENDAR_YEAR
public static long delta(long pStart)
System.currentTimeMillis()
).pStart
- the start timepublic static long delta(Date pStart)
System.currentTimeMillis()
).pStart
- the start timepublic static long currentTimeSecond()
roundToSecond(System.currentTimeMillis())
.public static long currentTimeMinute()
roundToMinute(System.currentTimeMillis())
.public static long currentTimeHour()
roundToHour(System.currentTimeMillis())
.public static long currentTimeDay()
roundToDay(System.currentTimeMillis())
.public static long roundToSecond(long pTime)
pTime
- timepublic static long roundToMinute(long pTime)
pTime
- timepublic static long roundToHour(long pTime)
pTime
- timepublic static long roundToHour(long pTime, TimeZone pTimeZone)
pTime
- timepTimeZone
- the timezone to use when roundingpublic static long roundToDay(long pTime)
pTime
- timepublic static long roundToDay(long pTime, TimeZone pTimeZone)
pTime
- timepTimeZone
- the timezone to use when roundingCopyright © 2018. All rights reserved.