@Override public Time get(ContentSet values) { Long timestamp = values.getAsLong(mTimestampField); if (timestamp == null) { // if the time stamp is null we return null return null; } // create a new Time for the given time zone, falling back to UTC if none is given String timezone = mTzField == null ? Time.TIMEZONE_UTC : values.getAsString(mTzField); Time value = new Time(timezone == null ? Time.TIMEZONE_UTC : timezone); // set the time stamp value.set(timestamp); // cache mAlldayField locally String allDayField = mAllDayField; // set the allday flag appropriately Integer allDayInt = allDayField == null ? null : values.getAsInteger(allDayField); if ((allDayInt != null && allDayInt != 0) || (allDayField == null && mAllDayDefault)) { value.set(value.monthDay, value.month, value.year); value.timezone = Time.TIMEZONE_UTC; } return value; }
@Override public Time getDefault(ContentSet values) { // create a new Time for the given time zone, falling back to the default time zone if none is // given String timezone = mTzField == null ? Time.TIMEZONE_UTC : values.getAsString(mTzField); Time value = new Time(timezone == null ? TimeZone.getDefault().getID() : timezone); value.setToNow(); Integer allDayInt = mAllDayField == null ? null : values.getAsInteger(mAllDayField); if ((allDayInt != null && allDayInt != 0) || (mAllDayField == null && mAllDayDefault)) { // make it an allday value value.set(value.monthDay, value.month, value.year); } else { value.second = 0; // round up to next quarter-hour value.minute = ((value.minute + 14) / 15) * 15; value.normalize(false); } return value; }