本文整理汇总了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);
}
}