use of java.util.SimpleTimeZone in project joda-time by JodaOrg.
the class TestLocalDate_Basics method testToDate_autumnDST.
public void testToDate_autumnDST() {
LocalDate base = new LocalDate(2007, 10, 2);
SimpleTimeZone testZone = new SimpleTimeZone(3600000, "NoMidnight", Calendar.APRIL, 2, 0, 0, Calendar.OCTOBER, 2, 0, 3600000);
TimeZone currentZone = TimeZone.getDefault();
try {
TimeZone.setDefault(testZone);
Date test = base.toDate();
check(base, 2007, 10, 2);
assertEquals("Tue Oct 02 00:00:00 GMT+02:00 2007", test.toString());
} finally {
TimeZone.setDefault(currentZone);
}
}
use of java.util.SimpleTimeZone in project opennms by OpenNMS.
the class TimestampUtils method getCalendar.
/**
* True if the backend uses doubles for time values. False if long is used.
*/
private Calendar getCalendar(int sign, int hr, int min, int sec) {
int rawOffset = sign * (((hr * 60 + min) * 60 + sec) * 1000);
if (calCache != null && calCacheZone == rawOffset)
return calCache;
final StringBuilder zoneID = new StringBuilder("GMT");
zoneID.append(sign < 0 ? '-' : '+');
if (hr < 10)
zoneID.append('0');
zoneID.append(hr);
if (min < 10)
zoneID.append('0');
zoneID.append(min);
if (sec < 10)
zoneID.append('0');
zoneID.append(sec);
TimeZone syntheticTZ = new SimpleTimeZone(rawOffset, zoneID.toString());
calCache = new GregorianCalendar(syntheticTZ);
calCacheZone = rawOffset;
return calCache;
}
use of java.util.SimpleTimeZone in project jphp by jphp-compiler.
the class WrapTimeZone method __construct.
@Signature({ @Arg("rawOffset"), @Arg("ID"), @Arg(value = "properties", type = HintType.ARRAY, optional = @Optional("null")) })
public Memory __construct(Environment env, Memory... args) {
if (args[2].isNull()) {
timeZone = new SimpleTimeZone(args[0].toInteger(), args[1].toString());
} else {
ArrayMemory props = args[2].toValue(ArrayMemory.class);
int startMonth = props.valueOfIndex("start_month").toInteger();
int startDay = props.valueOfIndex("start_day").toInteger();
int startDayOfWeek = props.valueOfIndex("start_day_of_week").toInteger();
int startTime = props.valueOfIndex("start_time").toInteger();
int endMonth = props.valueOfIndex("end_month").toInteger();
int endDay = props.valueOfIndex("end_day").toInteger();
int endDayOfWeek = props.valueOfIndex("end_day_of_week").toInteger();
int endTime = props.valueOfIndex("end_time").toInteger();
timeZone = new SimpleTimeZone(args[0].toInteger(), args[1].toString(), startMonth, startDay, startDayOfWeek, startTime, endMonth, endDay, endDayOfWeek, endTime);
}
return Memory.NULL;
}
use of java.util.SimpleTimeZone in project hibernate-orm by hibernate.
the class TypeTest method testTimeZoneType.
@Test
public void testTimeZoneType() {
final TimeZone original = new SimpleTimeZone(-1, "abc");
final TimeZone copy = new SimpleTimeZone(-1, "abc");
final TimeZone different = new SimpleTimeZone(-2, "xyz");
runBasicTests(TimeZoneType.INSTANCE, original, copy, different);
}
use of java.util.SimpleTimeZone in project j2objc by google.
the class SimpleDateFormatTest method test_format_time_zones.
public void test_format_time_zones() throws Exception {
Calendar cal = new GregorianCalendar(1999, Calendar.JUNE, 2, 15, 3, 6);
SimpleDateFormat format = new SimpleDateFormat("", Locale.ENGLISH);
format.setTimeZone(TimeZone.getTimeZone("EST"));
assertFormat(format, " z", cal, " GMT-5", DateFormat.TIMEZONE_FIELD);
Calendar temp2 = new GregorianCalendar(1999, Calendar.JANUARY, 12);
assertFormat(format, " z", temp2, " GMT-5", DateFormat.TIMEZONE_FIELD);
assertFormat(format, " zz", cal, " GMT-5", DateFormat.TIMEZONE_FIELD);
assertFormat(format, " zzz", cal, " GMT-5", DateFormat.TIMEZONE_FIELD);
assertFormat(format, " zzzz", cal, " GMT-05:00", DateFormat.TIMEZONE_FIELD);
assertFormat(format, " zzzz", temp2, " GMT-05:00", DateFormat.TIMEZONE_FIELD);
assertFormat(format, " zzzzz", cal, " GMT-05:00", DateFormat.TIMEZONE_FIELD);
format.setTimeZone(TimeZone.getTimeZone("America/New_York"));
assertFormat(format, " z", cal, " EDT", DateFormat.TIMEZONE_FIELD);
assertFormat(format, " z", temp2, " EST", DateFormat.TIMEZONE_FIELD);
assertFormat(format, " zz", cal, " EDT", DateFormat.TIMEZONE_FIELD);
assertFormat(format, " zzz", cal, " EDT", DateFormat.TIMEZONE_FIELD);
assertFormat(format, " zzzz", cal, " Eastern Daylight Time", DateFormat.TIMEZONE_FIELD);
assertFormat(format, " zzzz", temp2, " Eastern Standard Time", DateFormat.TIMEZONE_FIELD);
assertFormat(format, " zzzzz", cal, " Eastern Daylight Time", DateFormat.TIMEZONE_FIELD);
TimeZone tz0001 = new SimpleTimeZone(60000, "ONE MINUTE");
TimeZone tz0130 = new SimpleTimeZone(5400000, "ONE HOUR, THIRTY");
TimeZone tzMinus0130 = new SimpleTimeZone(-5400000, "NEG ONE HOUR, THIRTY");
format.setTimeZone(tz0001);
// test(" Z", cal, " +0001", DateFormat.TIMEZONE_FIELD);
// test(" ZZZZ", cal, " GMT+00:01", DateFormat.TIMEZONE_FIELD);
// test(" ZZZZZ", cal, " +00:01", DateFormat.TIMEZONE_FIELD);
format.setTimeZone(tz0130);
// test(" Z", cal, " +0130", DateFormat.TIMEZONE_FIELD);
format.setTimeZone(tzMinus0130);
// test(" Z", cal, " -0130", DateFormat.TIMEZONE_FIELD);
format.setTimeZone(tz0001);
assertFormat(format, " z", cal, " GMT+00:01", DateFormat.TIMEZONE_FIELD);
assertFormat(format, " zzzz", cal, " GMT+00:01", DateFormat.TIMEZONE_FIELD);
format.setTimeZone(tz0130);
assertFormat(format, " z", cal, " GMT+01:30", DateFormat.TIMEZONE_FIELD);
format.setTimeZone(tzMinus0130);
assertFormat(format, " z", cal, " GMT-01:30", DateFormat.TIMEZONE_FIELD);
}
Aggregations