FileDocCategorySizeDatePackage
UnixCalendar.javaAPI DocAndroid 5.1 API2864Thu Mar 12 22:22:42 GMT 2015com.android.server.usage

UnixCalendar

public class UnixCalendar extends Object
A handy calendar object that knows nothing of Locale's or TimeZones. This simplifies interval book-keeping. It is *NOT* meant to be used as a user-facing calendar, as it has no concept of Locale or TimeZone.

Fields Summary
private static final long
DAY_IN_MILLIS
private static final long
WEEK_IN_MILLIS
private static final long
MONTH_IN_MILLIS
private static final long
YEAR_IN_MILLIS
private long
mTime
Constructors Summary
public UnixCalendar(long time)


       
        mTime = time;
    
Methods Summary
public voidaddDays(int val)

        mTime += val * DAY_IN_MILLIS;
    
public voidaddMonths(int val)

        mTime += val * MONTH_IN_MILLIS;
    
public voidaddWeeks(int val)

        mTime += val * WEEK_IN_MILLIS;
    
public voidaddYears(int val)

        mTime += val * YEAR_IN_MILLIS;
    
public longgetTimeInMillis()

        return mTime;
    
public voidsetTimeInMillis(long time)

        mTime = time;
    
public static voidtruncateTo(com.android.server.usage.UnixCalendar calendar, int intervalType)

        switch (intervalType) {
            case UsageStatsManager.INTERVAL_YEARLY:
                calendar.truncateToYear();
                break;

            case UsageStatsManager.INTERVAL_MONTHLY:
                calendar.truncateToMonth();
                break;

            case UsageStatsManager.INTERVAL_WEEKLY:
                calendar.truncateToWeek();
                break;

            case UsageStatsManager.INTERVAL_DAILY:
                calendar.truncateToDay();
                break;

            default:
                throw new UnsupportedOperationException("Can't truncate date to interval " +
                        intervalType);
        }
    
public voidtruncateToDay()

        mTime -= mTime % DAY_IN_MILLIS;
    
public voidtruncateToMonth()

        mTime -= mTime % MONTH_IN_MILLIS;
    
public voidtruncateToWeek()

        mTime -= mTime % WEEK_IN_MILLIS;
    
public voidtruncateToYear()

        mTime -= mTime % YEAR_IN_MILLIS;