use of android.text.format.Time in project qksms by moezbhatti.
the class NetworkPolicyManager method computeNextCycleBoundary.
/**
* {@hide}
*/
public static long computeNextCycleBoundary(long currentTime, NetworkPolicy policy) {
if (policy.cycleDay == CYCLE_NONE) {
throw new IllegalArgumentException("Unable to compute boundary without cycleDay");
}
final Time now = new Time(policy.cycleTimezone);
now.set(currentTime);
// first, find cycle boundary for current month
final Time cycle = new Time(now);
cycle.hour = cycle.minute = cycle.second = 0;
snapToCycleDay(cycle, policy.cycleDay);
if (Time.compare(cycle, now) <= 0) {
// cycle boundary is before now, use next cycle boundary; start by
// pushing ourselves squarely into next month.
final Time nextMonth = new Time(now);
nextMonth.hour = nextMonth.minute = nextMonth.second = 0;
nextMonth.monthDay = 1;
nextMonth.month += 1;
nextMonth.normalize(true);
cycle.set(nextMonth);
snapToCycleDay(cycle, policy.cycleDay);
}
return cycle.toMillis(true);
}
use of android.text.format.Time in project chromeview by pwnall.
the class InputDialogContainer method normalizeTime.
private Time normalizeTime(int year, int month, int monthDay, int hour, int minute, int second) {
Time result = new Time();
if (year == 0 && month == 0 && monthDay == 0 && hour == 0 && minute == 0 && second == 0) {
Calendar cal = Calendar.getInstance();
result.set(cal.get(Calendar.SECOND), cal.get(Calendar.MINUTE), cal.get(Calendar.HOUR), cal.get(Calendar.DATE), cal.get(Calendar.MONTH), cal.get(Calendar.YEAR));
} else {
result.set(second, minute, hour, monthDay, month, year);
}
return result;
}
use of android.text.format.Time in project chromeview by pwnall.
the class InputDialogContainer method showDialog.
void showDialog(final int dialogType, int year, int month, int monthDay, int hour, int minute, int second) {
if (isDialogShowing())
mDialog.dismiss();
Time time = normalizeTime(year, month, monthDay, hour, minute, second);
if (dialogType == sTextInputTypeDate) {
mDialog = new DatePickerDialog(mContext, new DateListener(dialogType), time.year, time.month, time.monthDay);
mDialog.setTitle(mContext.getText(R.string.date_picker_dialog_title));
} else if (dialogType == sTextInputTypeTime) {
mDialog = new TimePickerDialog(mContext, new TimeListener(dialogType), time.hour, time.minute, DateFormat.is24HourFormat(mContext));
} else if (dialogType == sTextInputTypeDateTime || dialogType == sTextInputTypeDateTimeLocal) {
mDialog = new DateTimePickerDialog(mContext, new DateTimeListener(dialogType), time.year, time.month, time.monthDay, time.hour, time.minute, DateFormat.is24HourFormat(mContext));
} else if (dialogType == sTextInputTypeMonth) {
mDialog = new MonthPickerDialog(mContext, new MonthListener(dialogType), time.year, time.month);
}
mDialog.setButton(DialogInterface.BUTTON_POSITIVE, mContext.getText(R.string.date_picker_dialog_set), (DialogInterface.OnClickListener) mDialog);
mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, mContext.getText(android.R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mDialogAlreadyDismissed = true;
mInputActionDelegate.cancelDateTimeDialog();
}
});
mDialog.setButton(DialogInterface.BUTTON_NEUTRAL, mContext.getText(R.string.date_picker_dialog_clear), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
mDialogAlreadyDismissed = true;
mInputActionDelegate.replaceDateTime(dialogType, 0, 0, 0, 0, 0, 0);
}
});
mDialogAlreadyDismissed = false;
mDialog.show();
}
use of android.text.format.Time in project robolectric by robolectric.
the class ShadowTimeTest method shouldParseRfc3339_withQuestionableFormat.
@Test
@Config(maxSdk = KITKAT)
public // this fails on LOLLIPOP+; is the shadow impl of parse3339 correct for pre-LOLLIPOP?
void shouldParseRfc3339_withQuestionableFormat() {
for (String tz : Arrays.asList("Europe/Berlin", "America/Los Angeles", "Australia/Adelaide")) {
String desc = "Eval when local timezone is " + tz;
TimeZone.setDefault(TimeZone.getTimeZone(tz));
Time t = new Time("Europe/Berlin");
assertTrue(desc, t.parse3339("2008-10-13T16:30:50.999-03"));
assertEquals(desc, 2008, t.year);
assertEquals(desc, 9, t.month);
assertEquals(desc, 13, t.monthDay);
assertEquals(desc, 19, t.hour);
assertEquals(desc, 30, t.minute);
assertEquals(desc, 50, t.second);
assertEquals(desc, "UTC", t.timezone);
assertFalse(desc, t.allDay);
}
}
use of android.text.format.Time in project robolectric by robolectric.
the class ShadowTimeTest method shouldFormat.
@Test
public void shouldFormat() throws Exception {
Time t = new Time(Time.TIMEZONE_UTC);
t.set(3600000L);
assertEquals("Hello epoch 01 1970 01", t.format("Hello epoch %d %Y %d"));
assertEquals("Hello epoch 1:00 AM", t.format("Hello epoch %l:%M %p"));
}
Aggregations