本文整理汇总了Java中java.time.ZonedDateTime.getZone方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.getZone方法的具体用法?Java ZonedDateTime.getZone怎么用?Java ZonedDateTime.getZone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.ZonedDateTime
的用法示例。
在下文中一共展示了ZonedDateTime.getZone方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isEqualTo
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public final boolean isEqualTo(int index, ZonedDateTime value) {
if (value == null) {
return isNull(index);
} else {
final long epochMills = value.toInstant().toEpochMilli();
if (epochMills != values.get(index)) {
return false;
} else {
final ZoneId zoneId = value.getZone();
final short code1 = zoneIdMap1.get(zoneId);
final short code2 = zoneIds.get(index);
return code1 == code2;
}
}
}
示例2: isEqualTo
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public final boolean isEqualTo(int index, ZonedDateTime value) {
final long epochMillis = byteBuffer.getLong(index * BYTE_COUNT);
if (value == null) {
return epochMillis == nullValue;
} else {
final long valueAsEpochMills = value.toInstant().toEpochMilli();
if (epochMillis == valueAsEpochMills) {
return false;
} else {
final ZoneId zoneId = value.getZone();
final short code1 = zoneIdMap1.get(zoneId);
final short code2 = byteBuffer.getShort(index * BYTE_COUNT + 8);
return code1 == code2;
}
}
}
示例3: isEqualTo
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public final boolean isEqualTo(int index, ZonedDateTime value) {
if (value == null) {
return values[index] == nullValue;
} else {
final long epochMills = value.toInstant().toEpochMilli();
if (epochMills != values[index]) {
return false;
} else {
final ZoneId zoneId = value.getZone();
final short code1 = zoneIdMap1.get(zoneId);
final short code2 = zoneIds[index];
return code1 == code2;
}
}
}
示例4: isTimeOut
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public static boolean isTimeOut(ZonedDateTime start, ZonedDateTime target, long timeOutSeconds) {
if (start.getZone() != ZONE_UTC) {
start = toUtc(start);
}
if (target.getZone() != ZONE_UTC) {
target = toUtc(target);
}
final long runningInSeconds = ChronoUnit.SECONDS.between(start, target);
return runningInSeconds >= timeOutSeconds;
}
示例5: toUtc
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public static ZonedDateTime toUtc(ZonedDateTime zonedDateTime) {
if (zonedDateTime.getZone() != ZONE_UTC) {
return zonedDateTime.withZoneSameInstant(DateUtil.ZONE_UTC);
}
return zonedDateTime;
}
示例6: adjustTime
import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
* Adjusts the given time either rounding it up or down.
*
* @param time
* the time to adjust
* @param roundUp
* the rounding direction
* @param firstDayOfWeek
* the first day of the week (needed for rounding weeks)
* @return the adjusted time
*/
public ZonedDateTime adjustTime(ZonedDateTime time, boolean roundUp,
DayOfWeek firstDayOfWeek) {
Instant instant = time.toInstant();
ZoneId zoneId = time.getZone();
instant = adjustTime(instant, zoneId, roundUp, firstDayOfWeek);
return ZonedDateTime.ofInstant(instant, zoneId);
}
示例7: Interval
import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
* Constructs a new time interval with the given start and end zoned dates /
* times. The time zone will be initialized with the time zone of the start
* date time. However, if the zone ID of the second argument is different then
* an exception will be thrown.
*
* @throws IllegalArgumentException if two different time zones are used
*
* @param zonedStartDateTime the start date and time (e.g. Oct. 3rd, 2015, 6:15pm)
* @param zonedEndDateTime the end date and time
*/
public Interval(ZonedDateTime zonedStartDateTime, ZonedDateTime zonedEndDateTime) {
this(zonedStartDateTime.toLocalDateTime(), zonedEndDateTime.toLocalDateTime(), zonedStartDateTime.getZone());
if (!zonedStartDateTime.getZone().equals(zonedEndDateTime.getZone())) {
throw new IllegalArgumentException("the zoned start and end times use different time zones, zone1 = " + zonedStartDateTime.getZone() +
", zone2 = " + zonedEndDateTime.getZone());
}
}