Tools: context=
Download 1.5 Mb.
|
apk
- Bu sahifa navigatsiya:
- @param
/**
* Light extension of {@link Calendar} that strips away time, keeping only date information */ private static class DateOnlyCalendar extends GregorianCalendar { private static Pools.SimplePool private static DateOnlyCalendar obtain() {
public static DateOnlyCalendar today() { return fromTime(System.currentTimeMillis()); } public static DateOnlyCalendar fromTime(long timeMillis) { if (timeMillis < 0) { return null; } DateOnlyCalendar dateOnlyCalendar = DateOnlyCalendar.obtain(); dateOnlyCalendar.setTimeInMillis(timeMillis); dateOnlyCalendar.stripTime(); //noinspection WrongConstant dateOnlyCalendar.setFirstDayOfWeek(sWeekStart); return dateOnlyCalendar; } private DateOnlyCalendar() { super(); } /** * Checks if this instance falls in some month before given instance * @param other instance to check against * @return true if this instance is at least 1 'month' before, false otherwise */ public boolean monthBefore(DateOnlyCalendar other) { int day = other.get(DAY_OF_MONTH); other.set(DAY_OF_MONTH, 1); boolean before = getTimeInMillis() < other.getTimeInMillis(); other.set(DAY_OF_MONTH, day); return before; } /** * Checks if this instance falls in some month after given instance * @param other instance to check against * @return true if this instance is at least 1 'month' after, false otherwise */ public boolean monthAfter(DateOnlyCalendar other) { int day = other.get(DAY_OF_MONTH); other.set(DAY_OF_MONTH, other.getActualMaximum(DAY_OF_MONTH)); boolean after = getTimeInMillis() > other.getTimeInMillis(); other.set(DAY_OF_MONTH, day); return after; } public boolean sameMonth(DateOnlyCalendar other) { return get(YEAR) == other.get(YEAR) && get(MONTH) == other.get(MONTH); } void stripTime() { set(Calendar.HOUR_OF_DAY, 0); set(Calendar.MINUTE, 0); set(Calendar.SECOND, 0); set(Calendar.MILLISECOND, 0); } void recycle() { setTimeZone(TimeZone.getDefault()); sPools.release(this); } } } Download 1.5 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling