use of java.util.SimpleTimeZone in project robovm by robovm.
the class SimpleTimeZoneTest method test_getRawOffset.
/**
* java.util.SimpleTimeZone#getRawOffset()
*/
public void test_getRawOffset() {
// Test for method int java.util.SimpleTimeZone.getRawOffset()
st1 = new SimpleTimeZone(TimeZone.getTimeZone("EST").getRawOffset(), "EST");
assertTrue("Incorrect offset returned", st1.getRawOffset() == -(5 * 60 * 60 * 1000));
}
use of java.util.SimpleTimeZone in project robovm by robovm.
the class SimpleTimeZoneTest method test_equalsLjava_lang_Object.
/**
* java.util.SimpleTimeZone#equals(java.lang.Object)
*/
public void test_equalsLjava_lang_Object() {
// Test for method boolean
// java.util.SimpleTimeZone.equals(java.lang.Object)
TimeZone tz = TimeZone.getTimeZone("EST");
st1 = new SimpleTimeZone(tz.getRawOffset(), "EST");
st2 = new SimpleTimeZone(0, "EST");
assertFalse(st1.equals(st2));
st1.setRawOffset(st2.getRawOffset());
assertTrue(st1.equals(st2));
}
use of java.util.SimpleTimeZone in project XobotOS by xamarin.
the class DERUTCTime method getAdjustedDate.
/**
* return the time as an adjusted date
* in the range of 1950 - 2049.
*
* @return a date in the range of 1950 to 2049.
* @exception ParseException if the date string cannot be parsed.
*/
public Date getAdjustedDate() throws ParseException {
SimpleDateFormat dateF = new SimpleDateFormat("yyyyMMddHHmmssz");
dateF.setTimeZone(new SimpleTimeZone(0, "Z"));
return dateF.parse(getAdjustedTime());
}
use of java.util.SimpleTimeZone in project XobotOS by xamarin.
the class SimpleDateFormat method parseTimeZone.
private int parseTimeZone(String string, int offset) {
boolean foundGMT = string.regionMatches(offset, "GMT", 0, 3);
if (foundGMT) {
offset += 3;
}
char sign;
if (offset < string.length() && ((sign = string.charAt(offset)) == '+' || sign == '-')) {
ParsePosition position = new ParsePosition(offset + 1);
Number result = numberFormat.parse(string, position);
if (result == null) {
return -position.getErrorIndex() - 1;
}
int hour = result.intValue();
int raw = hour * 3600000;
int index = position.getIndex();
if (index < string.length() && string.charAt(index) == ':') {
position.setIndex(index + 1);
result = numberFormat.parse(string, position);
if (result == null) {
return -position.getErrorIndex() - 1;
}
int minute = result.intValue();
raw += minute * 60000;
} else if (hour >= 24) {
raw = (hour / 100 * 3600000) + (hour % 100 * 60000);
}
if (sign == '-') {
raw = -raw;
}
calendar.setTimeZone(new SimpleTimeZone(raw, ""));
return position.getIndex();
}
if (foundGMT) {
calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
return offset;
}
String[][] zones = formatData.internalZoneStrings();
for (String[] element : zones) {
for (int j = TimeZones.LONG_NAME; j < TimeZones.NAME_COUNT; j++) {
if (string.regionMatches(true, offset, element[j], 0, element[j].length())) {
TimeZone zone = TimeZone.getTimeZone(element[TimeZones.OLSON_NAME]);
if (zone == null) {
return -offset - 1;
}
int raw = zone.getRawOffset();
if (j == TimeZones.LONG_NAME_DST || j == TimeZones.SHORT_NAME_DST) {
/*
* TODO, http://b/4723412
* We can't use TimeZone#getDSTSavings here because that
* will return 0 if the zone no longer uses DST. We
* should change this to use TimeZone.getOffset(long),
* which requires the complete date to be parsed first.
*/
raw += 3600000;
}
calendar.setTimeZone(new SimpleTimeZone(raw, ""));
return offset + element[j].length();
}
}
}
return -offset - 1;
}
use of java.util.SimpleTimeZone in project OpenAM by OpenRock.
the class AgentBase method getLocalDateAsGMTString.
protected String getLocalDateAsGMTString() {
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z");
dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
Date date = new Date();
return dateFormat.format(date);
}
Aggregations