use of java.util.GregorianCalendar in project j2objc by google.
the class GregorianCalendarTest method test_getMaximumI.
/**
* java.util.GregorianCalendar#getMaximum(int)
*/
public void test_getMaximumI() {
// Test for method int java.util.GregorianCalendar.getMaximum(int)
GregorianCalendar gc = new GregorianCalendar();
assertEquals("Wrong maximum value for DAY_OF_MONTH", 31, gc.getMaximum(Calendar.DAY_OF_MONTH));
assertTrue("Wrong maximum value for MONTH", gc.getMaximum(Calendar.MONTH) == Calendar.DECEMBER);
assertEquals("Wrong maximum value for HOUR_OF_DAY", 23, gc.getMaximum(Calendar.HOUR_OF_DAY));
assertEquals("Wrong maximum value for HOUR", 11, gc.getMaximum(Calendar.HOUR));
BitSet result = new BitSet();
Vector values = new Vector();
int[] max = { 1, 292278994, 11, 53, 6, 31, 366, 7, 6, 1, 11, 23, 59, 59, 999, 50400000, 7200000 };
for (int i = 0; i < max.length; i++) {
if (gc.getMaximum(i) != max[i]) {
result.set(i);
values.add(new Integer(gc.getMaximum(i)));
}
}
assertTrue("Wrong max for " + result + " = " + values, result.length() == 0);
}
use of java.util.GregorianCalendar in project j2objc by google.
the class GregorianCalendarTest method test_clone.
/**
* java.util.GregorianCalendar#clone()
*/
public void test_clone() {
// Regression for HARMONY-498
GregorianCalendar gCalend = new GregorianCalendar();
gCalend.set(Calendar.MILLISECOND, 0);
int dayOfMonth = gCalend.get(Calendar.DAY_OF_MONTH);
// create clone object and change date
GregorianCalendar gCalendClone = (GregorianCalendar) gCalend.clone();
gCalendClone.add(Calendar.DATE, 1);
assertEquals("Before", dayOfMonth, gCalend.get(Calendar.DAY_OF_MONTH));
//changes nothing
gCalend.set(Calendar.MILLISECOND, 0);
assertEquals("After", dayOfMonth, gCalend.get(Calendar.DAY_OF_MONTH));
}
use of java.util.GregorianCalendar in project j2objc by google.
the class SimpleTimeZoneTest method test_setEndRuleIIIIZ.
/**
* java.util.SimpleTimeZone#setEndRule(int, int, int, int, boolean)
*/
public void test_setEndRuleIIIIZ() {
// Test for method void java.util.SimpleTimeZone.setEndRule(int, int,
// int, int, boolean)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
// Spec indicates that both end and start must be set or result is
// undefined
st.setStartRule(Calendar.NOVEMBER, 8, Calendar.SUNDAY, 1, false);
st.setEndRule(Calendar.NOVEMBER, 15, Calendar.SUNDAY, 1, true);
assertTrue("StartRule improperly set1", st.useDaylightTime());
assertTrue("StartRule improperly set2", st.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER, 7, 12, 0).getTime())));
assertTrue("StartRule improperly set3", st.inDaylightTime((new GregorianCalendar(1999, Calendar.NOVEMBER, 20, 12, 0).getTime())));
assertTrue("StartRule improperly set4", !(st.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER, 6, 12, 0).getTime())));
assertTrue("StartRule improperly set5", !(st.inDaylightTime(new GregorianCalendar(1999, Calendar.NOVEMBER, 21, 12, 0).getTime())));
try {
st.setEndRule(20, 15, Calendar.SUNDAY, 1, true);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setEndRule(Calendar.NOVEMBER, 35, Calendar.SUNDAY, 1, true);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setEndRule(Calendar.NOVEMBER, 15, 12, 1, true);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setEndRule(Calendar.NOVEMBER, 15, Calendar.SUNDAY, -1, true);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
}
use of java.util.GregorianCalendar in project j2objc by google.
the class SimpleTimeZoneTest method test_setEndRuleIIII.
/**
* java.util.SimpleTimeZone#setEndRule(int, int, int, int)
*/
public void test_setEndRuleIIII() {
// Test for method void java.util.SimpleTimeZone.setEndRule(int, int,
// int, int)
SimpleTimeZone st = new SimpleTimeZone(1000, "Test_TZ");
// Spec indicates that both end and start must be set or result is
// undefined
st.setStartRule(Calendar.NOVEMBER, 1, Calendar.SUNDAY, 0);
st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, 0);
assertTrue("StartRule improperly set1", st.useDaylightTime());
assertTrue("StartRule improperly set2", st.inDaylightTime(new GregorianCalendar(1998, Calendar.NOVEMBER, 13).getTime()));
assertTrue("StartRule improperly set3", !(st.inDaylightTime(new GregorianCalendar(1998, Calendar.OCTOBER, 13).getTime())));
try {
st.setEndRule(12, -1, Calendar.SUNDAY, 0);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setEndRule(Calendar.NOVEMBER, 10, Calendar.SUNDAY, 0);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setEndRule(Calendar.NOVEMBER, -1, 8, 0);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
try {
st.setEndRule(Calendar.NOVEMBER, -1, Calendar.SUNDAY, -10);
fail("IllegalArgumentException is not thrown.");
} catch (IllegalArgumentException iae) {
//expected
}
}
use of java.util.GregorianCalendar in project j2objc by google.
the class ASN1Time method getDecodedObject.
@Override
public Object getDecodedObject(BerInputStream in) throws IOException {
GregorianCalendar c = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
c.set(Calendar.YEAR, in.times[0]);
c.set(Calendar.MONTH, in.times[1] - 1);
c.set(Calendar.DAY_OF_MONTH, in.times[2]);
c.set(Calendar.HOUR_OF_DAY, in.times[3]);
c.set(Calendar.MINUTE, in.times[4]);
c.set(Calendar.SECOND, in.times[5]);
c.set(Calendar.MILLISECOND, in.times[6]);
return c.getTime();
}
Aggregations