use of java.util.SimpleTimeZone in project jdk8u_jdk by JetBrains.
the class SimpleDateFormat method readObject.
/**
* After reading an object from the input stream, the format
* pattern in the object is verified.
* <p>
* @exception InvalidObjectException if the pattern is invalid
*/
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
stream.defaultReadObject();
try {
compiledPattern = compile(pattern);
} catch (Exception e) {
throw new InvalidObjectException("invalid pattern");
}
if (serialVersionOnStream < 1) {
// didn't have defaultCenturyStart field
initializeDefaultCentury();
} else {
// fill in dependent transient field
parseAmbiguousDatesAsAfter(defaultCenturyStart);
}
serialVersionOnStream = currentSerialVersion;
// If the deserialized object has a SimpleTimeZone, try
// to replace it with a ZoneInfo equivalent in order to
// be compatible with the SimpleTimeZone-based
// implementation as much as possible.
TimeZone tz = getTimeZone();
if (tz instanceof SimpleTimeZone) {
String id = tz.getID();
TimeZone zi = TimeZone.getTimeZone(id);
if (zi != null && zi.hasSameRules(tz) && zi.getID().equals(id)) {
setTimeZone(zi);
}
}
}
use of java.util.SimpleTimeZone in project joda-time by JodaOrg.
the class TestLocalDateTime_Basics method testToDate_springDST_2Hour40Savings.
public void testToDate_springDST_2Hour40Savings() {
LocalDateTime base = new LocalDateTime(2007, 4, 2, 0, 20, 0, 0);
SimpleTimeZone testZone = new SimpleTimeZone(3600000, "NoMidnight", Calendar.APRIL, 2, 0, 0, Calendar.OCTOBER, 2, 0, 3600000, (3600000 / 6) * 16);
TimeZone currentZone = TimeZone.getDefault();
try {
TimeZone.setDefault(testZone);
Date test = base.toDate();
check(base, 2007, 4, 2, 0, 20, 0, 0);
assertEquals("Mon Apr 02 02:40:00 GMT+03:40 2007", test.toString());
} finally {
TimeZone.setDefault(currentZone);
}
}
use of java.util.SimpleTimeZone in project joda-time by JodaOrg.
the class TestLocalDateTime_Basics method testToDate_springDST.
public void testToDate_springDST() {
LocalDateTime base = new LocalDateTime(2007, 4, 2, 0, 20, 0, 0);
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, 4, 2, 0, 20, 0, 0);
assertEquals("Mon Apr 02 01:00:00 GMT+02:00 2007", test.toString());
} finally {
TimeZone.setDefault(currentZone);
}
}
use of java.util.SimpleTimeZone in project joda-time by JodaOrg.
the class TestLocalDateTime_Basics method testToDate_autumnDST_Zone.
public void testToDate_autumnDST_Zone() {
LocalDateTime base = new LocalDateTime(2007, 10, 2, 0, 20, 30, 0);
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(TimeZone.getDefault());
check(base, 2007, 10, 2, 0, 20, 30, 0);
assertEquals("Tue Oct 02 00:20:30 GMT+02:00 2007", test.toString());
} finally {
TimeZone.setDefault(currentZone);
}
}
use of java.util.SimpleTimeZone in project joda-time by JodaOrg.
the class TestLocalDateTime_Basics method testToDate_springDST_Zone.
public void testToDate_springDST_Zone() {
LocalDateTime base = new LocalDateTime(2007, 4, 2, 0, 20, 0, 0);
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(TimeZone.getDefault());
check(base, 2007, 4, 2, 0, 20, 0, 0);
assertEquals("Mon Apr 02 01:00:00 GMT+02:00 2007", test.toString());
} finally {
TimeZone.setDefault(currentZone);
}
}
Aggregations