本文整理汇总了Java中org.joda.time.DateTimeZone.convertLocalToUTC方法的典型用法代码示例。如果您正苦于以下问题:Java DateTimeZone.convertLocalToUTC方法的具体用法?Java DateTimeZone.convertLocalToUTC怎么用?Java DateTimeZone.convertLocalToUTC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joda.time.DateTimeZone
的用法示例。
在下文中一共展示了DateTimeZone.convertLocalToUTC方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPartition
import org.joda.time.DateTimeZone; //导入方法依赖的package包/类
public static long getPartition(long timeGranularityMs, long timestamp, DateTimeZone timeZone) {
long adjustedTimeStamp = timeZone.convertUTCToLocal(timestamp);
long partitionedTime = (adjustedTimeStamp / timeGranularityMs) * timeGranularityMs;
return timeZone.convertLocalToUTC(partitionedTime, false);
}
示例2: getPartition
import org.joda.time.DateTimeZone; //导入方法依赖的package包/类
private static long getPartition(long timeGranularityMs, long timestamp, DateTimeZone timeZone) {
long adjustedTimeStamp = timeZone.convertUTCToLocal(timestamp);
long partitionedTime = (adjustedTimeStamp / timeGranularityMs) * timeGranularityMs;
return timeZone.convertLocalToUTC(partitionedTime, false);
}
示例3: getNextTimeAdjustedByDay
import org.joda.time.DateTimeZone; //导入方法依赖的package包/类
/**
* Calculates next period of periodMs after currentTimeMs starting from midnight in given timeZone.
* If the next period is in next day then 12am of next day will be returned
* @param currentTimeMs time to calculate at
* @param periodMs period in ms
* @param timeZone timezone to get midnight time
* @return timestamp in ms
*/
public static long getNextTimeAdjustedByDay(long currentTimeMs, long periodMs, DateTimeZone timeZone) {
long startOfDay = timeZone.convertLocalToUTC(timeZone.convertUTCToLocal(currentTimeMs) / DAY_IN_MS * DAY_IN_MS, true);
long nextPeriodOffset = ((currentTimeMs - startOfDay) / periodMs + 1) * periodMs;
long offset = Math.min(nextPeriodOffset, DAY_IN_MS);
return startOfDay + offset;
}