use of java.util.GregorianCalendar in project j2objc by google.
the class DateTest method test_setMonthI.
/**
* java.util.Date#setMonth(int)
*/
public void test_setMonthI() {
// Test for method void java.util.Date.setMonth(int)
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9).getTime();
d.setMonth(0);
assertEquals("Set incorrect month", 0, d.getMonth());
}
use of java.util.GregorianCalendar in project j2objc by google.
the class DateTest method test_getMinutes.
/**
* java.util.Date#getMinutes()
*/
public void test_getMinutes() {
// Test for method int java.util.Date.getMinutes()
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9).getTime();
assertEquals("Returned incorrect minutes", 9, d.getMinutes());
}
use of java.util.GregorianCalendar in project j2objc by google.
the class DateTest method test_getDate.
/**
* java.util.Date#getDate()
*/
public void test_getDate() {
// Test for method int java.util.Date.getDate()
Date d = new GregorianCalendar(1998, Calendar.OCTOBER, 13, 19, 9).getTime();
assertEquals("Returned incorrect date", 13, d.getDate());
}
use of java.util.GregorianCalendar in project j2objc by google.
the class DateTest method test_parseLjava_lang_String.
/**
* java.util.Date#parse(java.lang.String)
*/
public void test_parseLjava_lang_String() {
// Test for method long java.util.Date.parse(java.lang.String)
Date d = new Date(Date.parse("13 October 1998"));
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(d);
assertEquals("Parsed incorrect month", 9, cal.get(Calendar.MONTH));
assertEquals("Parsed incorrect year", 1998, cal.get(Calendar.YEAR));
assertEquals("Parsed incorrect date", 13, cal.get(Calendar.DATE));
d = new Date(Date.parse("Jan-12 1999"));
assertTrue("Wrong parsed date 1", d.equals(new GregorianCalendar(1999, 0, 12).getTime()));
d = new Date(Date.parse("Jan12-1999"));
assertTrue("Wrong parsed date 2", d.equals(new GregorianCalendar(1999, 0, 12).getTime()));
d = new Date(Date.parse("Jan12 69-1"));
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
cal.clear();
cal.set(1969, Calendar.JANUARY, 12, 1, 0);
assertTrue("Wrong parsed date 3", d.equals(cal.getTime()));
d = new Date(Date.parse("6:45:13 3/2/1200 MST"));
cal.setTimeZone(TimeZone.getTimeZone("MST"));
cal.clear();
cal.set(1200, 2, 2, 6, 45, 13);
assertTrue("Wrong parsed date 4", d.equals(cal.getTime()));
d = new Date(Date.parse("Mon, 22 Nov 1999 12:52:06 GMT"));
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
cal.clear();
cal.set(1999, Calendar.NOVEMBER, 22, 12, 52, 06);
assertTrue("Wrong parsed date 5", d.equals(cal.getTime()));
try {
// Regression for HARMONY-259
Date.parse(null);
fail("Date.parse(null) should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// expected
}
// Regression for HARMONY-102
assertEquals("Assert 0: parse failure", -5400000, Date.parse("Sat, 1 Jan 1970 +0130 00:00:00"));
assertEquals("Assert 1: parse failure", 858600000, Date.parse("00:00:00 GMT +0130 Sat, 11 Jan 1970"));
}
use of java.util.GregorianCalendar in project j2objc by google.
the class SimpleDateFormatTest method test_set2DigitYearStartLjava_util_Date.
public void test_set2DigitYearStartLjava_util_Date() {
// Test for method void
// java.text.SimpleDateFormat.set2DigitYearStart(java.util.Date)
SimpleDateFormat f1 = new SimpleDateFormat("yy");
f1.set2DigitYearStart(new GregorianCalendar(1950, Calendar.JANUARY, 1).getTime());
Calendar cal = new GregorianCalendar();
try {
cal.setTime(f1.parse("49"));
assertEquals("Incorrect year 2049", 2049, cal.get(Calendar.YEAR));
cal.setTime(f1.parse("50"));
int year = cal.get(Calendar.YEAR);
assertTrue("Incorrect year 1950: " + year, year == 1950);
f1.applyPattern("y");
cal.setTime(f1.parse("00"));
assertEquals("Incorrect year 2000", 2000, cal.get(Calendar.YEAR));
f1.applyPattern("yyy");
cal.setTime(f1.parse("50"));
assertEquals("Incorrect year 50", 50, cal.get(Calendar.YEAR));
} catch (ParseException e) {
fail("ParseException");
}
}
Aggregations