本文整理匯總了Java中org.joda.time.DateTimeZone.getDefault方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTimeZone.getDefault方法的具體用法?Java DateTimeZone.getDefault怎麽用?Java DateTimeZone.getDefault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.DateTimeZone
的用法示例。
在下文中一共展示了DateTimeZone.getDefault方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import org.joda.time.DateTimeZone; //導入方法依賴的package包/類
@Override
public ServerTimeZoneResponse execute(ServerTimeZoneRequest request, SessionContext context) {
Date first = null, last = null;
for (Session session: SessionDAO.getInstance().findAll()) {
if (first == null || first.after(session.getEventBeginDate()))
first = session.getEventBeginDate();
if (last == null || last.before(session.getEventEndDate()))
last = session.getEventEndDate();
}
DateTimeZone zone = DateTimeZone.getDefault();
int offsetInMinutes = zone.getOffset(first.getTime()) / 60000;
ServerTimeZoneResponse ret = new ServerTimeZoneResponse();
ret.setId(zone.getID());
ret.addName(zone.getName(new Date().getTime()));
ret.setTimeZoneOffsetInMinutes(offsetInMinutes);
long time = first.getTime();
long transition;
while (time != (transition = zone.nextTransition(time)) && time < last.getTime()) {
int adjustment = (zone.getOffset(transition) / 60000) - offsetInMinutes;
ret.addTransition((int)(transition / 3600000), adjustment);
time = transition;
}
return ret;
}
示例2: getLongExpressedValue
import org.joda.time.DateTimeZone; //導入方法依賴的package包/類
private static long getLongExpressedValue(Object value) {
if (value instanceof Date) {
long storageTime = ((Date) value).getTime();
// convert date from VM current time zone to UTC
long utcMillis = storageTime + DateTimeZone.getDefault().getOffset(storageTime);
return TimeUnit.MILLISECONDS.toDays(utcMillis);
}
if (value instanceof Timestamp) {
long parsedJvmMillis = ((Timestamp) value).getTime();
DateTimeZone jvmTimeZone = DateTimeZone.getDefault();
long convertedMillis = jvmTimeZone.convertUTCToLocal(parsedJvmMillis);
return convertedMillis;
}
if (value instanceof Float) {
return floatToRawIntBits(((Float) value));
}
return ((Number) value).longValue();
}
示例3: stringToTimestampChangeTZ
import org.joda.time.DateTimeZone; //導入方法依賴的package包/類
@Test
public void stringToTimestampChangeTZ() {
DateTimeZone defaultTZ = DateTimeZone.getDefault();
try {
DateTimeZone.setDefault(DateTimeZone.forID("America/Los_Angeles"));
assertEquals(1236478747000L, formatTimeStamp("2009-03-08 02:19:07", getFormatterForFormatString("YYYY-MM-DD HH:MI:SS")));
} finally {
DateTimeZone.setDefault(defaultTZ);
}
}
示例4: stringToTimestampChangeTZOffset
import org.joda.time.DateTimeZone; //導入方法依賴的package包/類
@Test
public void stringToTimestampChangeTZOffset() {
DateTimeZone defaultTZ = DateTimeZone.getDefault();
try {
assertEquals(calculateTime("2008-09-15 10:53:00"), formatTimeStamp("2008-09-15T15:53:00+0500", getFormatterForFormatString("YYYY-MM-DD\"T\"HH24:MI:SSTZO")));
assertEquals(calculateTime("2011-01-01 04:00:00"), formatTimeStamp("2010-12-31T23:00:00-0500", getFormatterForFormatString("YYYY-MM-DD\"T\"HH24:MI:SSTZO")));
assertEquals(calculateTime("2010-12-31 23:00:00"), formatTimeStamp("2010-12-31T23:00:00", getFormatterForFormatString("YYYY-MM-DD\"T\"HH24:MI:SS")));
} finally {
DateTimeZone.setDefault(defaultTZ);
}
}