Package org.greenrobot.essentials
Class DateUtils
java.lang.Object
org.greenrobot.essentials.DateUtils
Simple Date and time utils.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Calendar objects are rather expensive: for heavy usage it's a good idea to use a single instance per thread instead of calling Calendar.getInstance() multiple times. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic long
addDays
(long time, int days) static void
static int
getDayAsReadableInt
(long time) Readable yyyyMMdd int representation of a day, which is also sortable.static int
getDayAsReadableInt
(Calendar calendar) Readable yyyyMMdd representation of a day, which is also sortable.static int
getDayDifference
(long time1, long time2) static int
getDayDifferenceOfReadableInts
(int dayOfBroadcast1, int dayOfBroadcast2) static long
getTimeForDay
(int year, int month, int day) static long
getTimeForDay
(Calendar calendar, int year, int month, int day) static long
getTimeFromDayReadableInt
(int day) Returns midnight of the given day.static long
getTimeFromDayReadableInt
(Calendar calendar, int readableDay, int hour) static void
Sets hour, minutes, seconds and milliseconds to the given values.
-
Field Details
-
calendarThreadLocal
-
-
Constructor Details
-
DateUtils
public DateUtils()
-
-
Method Details
-
getTimeForDay
public static long getTimeForDay(int year, int month, int day) -
getTimeForDay
- Parameters:
calendar
- helper object needed for conversion
-
setTime
public static void setTime(Calendar calendar, int hourOfDay, int minute, int second, int millisecond) Sets hour, minutes, seconds and milliseconds to the given values. Leaves date info untouched. -
getDayAsReadableInt
public static int getDayAsReadableInt(long time) Readable yyyyMMdd int representation of a day, which is also sortable. -
getDayAsReadableInt
Readable yyyyMMdd representation of a day, which is also sortable. -
getTimeFromDayReadableInt
public static long getTimeFromDayReadableInt(int day) Returns midnight of the given day. -
getTimeFromDayReadableInt
- Parameters:
calendar
- helper object needed for conversion
-
getDayDifferenceOfReadableInts
public static int getDayDifferenceOfReadableInts(int dayOfBroadcast1, int dayOfBroadcast2) -
getDayDifference
public static int getDayDifference(long time1, long time2) -
addDays
public static long addDays(long time, int days) -
addDays
-