當前位置: 首頁>>代碼示例>>Java>>正文


Java DateTimeZone.nextTransition方法代碼示例

本文整理匯總了Java中org.joda.time.DateTimeZone.nextTransition方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTimeZone.nextTransition方法的具體用法?Java DateTimeZone.nextTransition怎麽用?Java DateTimeZone.nextTransition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.DateTimeZone的用法示例。


在下文中一共展示了DateTimeZone.nextTransition方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:25,代碼來源:ServerTimeZoneBackend.java

示例2: nastyDate

import org.joda.time.DateTimeZone; //導入方法依賴的package包/類
/**
 * To be even more nasty, go to a transition in the selected time zone.
 * In one third of the cases stay there, otherwise go half a unit back or forth
 */
private static long nastyDate(long initialDate, DateTimeZone timezone, long unitMillis) {
    long date = timezone.nextTransition(initialDate);
    if (randomBoolean()) {
        return date + (randomLong() % unitMillis);  // positive and negative offset possible
    } else {
        return date;
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,代碼來源:TimeZoneRoundingTests.java


注:本文中的org.joda.time.DateTimeZone.nextTransition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。