use of android.text.format.Time in project android_frameworks_base by ParanoidAndroid.
the class TimeTest method testParse33390.
@SmallTest
public void testParse33390() throws Exception {
Time t = new Time(Time.TIMEZONE_UTC);
t.parse3339("1980-05-23");
if (!t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23) {
fail("Did not parse all-day date correctly");
}
t.parse3339("1980-05-23T09:50:50");
if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || t.hour != 9 || t.minute != 50 || t.second != 50 || t.gmtoff != 0) {
fail("Did not parse timezone-offset-less date correctly");
}
t.parse3339("1980-05-23T09:50:50Z");
if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || t.hour != 9 || t.minute != 50 || t.second != 50 || t.gmtoff != 0) {
fail("Did not parse UTC date correctly");
}
t.parse3339("1980-05-23T09:50:50.0Z");
if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || t.hour != 9 || t.minute != 50 || t.second != 50 || t.gmtoff != 0) {
fail("Did not parse UTC date correctly");
}
t.parse3339("1980-05-23T09:50:50.12Z");
if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || t.hour != 9 || t.minute != 50 || t.second != 50 || t.gmtoff != 0) {
fail("Did not parse UTC date correctly");
}
t.parse3339("1980-05-23T09:50:50.123Z");
if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || t.hour != 9 || t.minute != 50 || t.second != 50 || t.gmtoff != 0) {
fail("Did not parse UTC date correctly");
}
// The time should be normalized to UTC
t.parse3339("1980-05-23T09:50:50-01:05");
if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || t.hour != 10 || t.minute != 55 || t.second != 50 || t.gmtoff != 0) {
fail("Did not parse timezone-offset date correctly");
}
// The time should be normalized to UTC
t.parse3339("1980-05-23T09:50:50.123-01:05");
if (t.allDay || t.year != 1980 || t.month != 04 || t.monthDay != 23 || t.hour != 10 || t.minute != 55 || t.second != 50 || t.gmtoff != 0) {
fail("Did not parse timezone-offset date correctly");
}
try {
t.parse3339("1980");
fail("Did not throw error on truncated input length");
} catch (TimeFormatException e) {
// Successful
}
try {
t.parse3339("1980-05-23T09:50:50.123+");
fail("Did not throw error on truncated timezone offset");
} catch (TimeFormatException e1) {
// Successful
}
try {
t.parse3339("1980-05-23T09:50:50.123+05:0");
fail("Did not throw error on truncated timezone offset");
} catch (TimeFormatException e1) {
// Successful
}
}
use of android.text.format.Time in project android_frameworks_base by ParanoidAndroid.
the class TimeTest method testClear0.
@SmallTest
public void testClear0() throws Exception {
Time t = new Time(Time.TIMEZONE_UTC);
t.clear(Time.TIMEZONE_UTC);
}
use of android.text.format.Time in project android_frameworks_base by ParanoidAndroid.
the class TimeTest method testMillis0.
@SmallTest
public void testMillis0() throws Exception {
Time t = new Time(Time.TIMEZONE_UTC);
t.set(0, 0, 0, 1, 1, 2006);
long r = t.toMillis(true);
// System.out.println("r=" + r);
t.set(1, 0, 0, 1, 1, 2006);
r = t.toMillis(true);
// System.out.println("r=" + r);
}
use of android.text.format.Time in project android_frameworks_base by ParanoidAndroid.
the class TimeTest method testNormalize0.
@SmallTest
public void testNormalize0() throws Exception {
Time t = new Time(Time.TIMEZONE_UTC);
t.parse("20060432T010203");
t.normalize(false);
// System.out.println("got: " + t.year + '-'
// + t.month + '-' + t.monthDay
// + ' ' + t.hour + ':' + t.minute
// + ':' + t.second
// + "( " + t.isDst + ',' + t.gmtoff
// + ',' + t.weekDay
// + ',' + t.yearDay + ')');
}
use of android.text.format.Time in project android_frameworks_base by ParanoidAndroid.
the class TimeTest method disableTestGetJulianDay.
@Suppress
public void disableTestGetJulianDay() throws Exception {
Time time = new Time();
// same Julian day.
for (int monthDay = 1; monthDay <= 366; monthDay++) {
for (int zoneIndex = 0; zoneIndex < mTimeZones.length; zoneIndex++) {
// We leave the "month" as zero because we are changing the
// "monthDay" from 1 to 366. The call to normalize() will
// then change the "month" (but we don't really care).
time.set(0, 0, 0, monthDay, 0, 2008);
time.timezone = mTimeZones[zoneIndex];
long millis = time.normalize(true);
if (zoneIndex == 0) {
Log.i("TimeTest", time.format("%B %d, %Y"));
}
// This is the Julian day for 12am for this day of the year
int julianDay = Time.getJulianDay(millis, time.gmtoff);
// Julian day.
for (int hour = 0; hour < 24; hour++) {
for (int minute = 0; minute < 60; minute += 15) {
time.set(0, minute, hour, monthDay, 0, 2008);
millis = time.normalize(true);
int day = Time.getJulianDay(millis, time.gmtoff);
if (day != julianDay) {
Log.e("TimeTest", "Julian day: " + day + " at time " + time.hour + ":" + time.minute + " != today's Julian day: " + julianDay + " timezone: " + time.timezone);
}
assertEquals(day, julianDay);
}
}
}
}
}
Aggregations