本文整理了Java中java.time.ZoneOffset.equals()
方法的一些代码示例,展示了ZoneOffset.equals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneOffset.equals()
方法的具体详情如下:
包路径:java.time.ZoneOffset
类名称:ZoneOffset
方法名:equals
[英]Checks if this offset is equal to another offset.
The comparison is based on the amount of the offset in seconds. This is equivalent to a comparison by ID.
[中]检查此偏移是否等于另一个偏移。
比较基于以秒为单位的偏移量。这相当于通过ID进行比较。
代码示例来源:origin: neo4j/neo4j
private static String currentTimeZoneOffsetString()
{
ZoneOffset offset = OffsetDateTime.now().getOffset();
return offset.equals( UTC ) ? "+0000" : offset.toString().replace( ":", "" );
}
}
代码示例来源:origin: neo4j/neo4j
if ( !expected.equals( offset ) )
代码示例来源:origin: embulk/embulk
if (!defaultZoneOffset.equals(ZoneOffset.UTC)) {
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public DateFormatter withZone(ZoneId zoneId) {
if (ZoneOffset.UTC.equals(zoneId) == false) {
throw new IllegalArgumentException(pattern() + " date formatter can only be in zone offset UTC");
}
return INSTANCE;
}
代码示例来源:origin: com.github.seratch/java-time-backport
@Override
public boolean isValidOffset(LocalDateTime dateTime, ZoneOffset offset) {
return this.offset.equals(offset);
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Returns a new time based on this one, returning {@code this} where possible.
*
* @param time the time to create with, not null
* @param offset the zone offset to create with, not null
*/
private OffsetTime with(LocalTime time, ZoneOffset offset) {
if (this.time == time && this.offset.equals(offset)) {
return this;
}
return new OffsetTime(time, offset);
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Returns a new date-time based on this one, returning {@code this} where possible.
*
* @param dateTime the date-time to create with, not null
* @param offset the zone offset to create with, not null
*/
private OffsetDateTime with(LocalDateTime dateTime, ZoneOffset offset) {
if (this.dateTime == dateTime && this.offset.equals(offset)) {
return this;
}
return new OffsetDateTime(dateTime, offset);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
@Override
public DateFormatter withZone(ZoneId zoneId) {
if (ZoneOffset.UTC.equals(zoneId) == false) {
throw new IllegalArgumentException(pattern() + " date formatter can only be in zone offset UTC");
}
return INSTANCE;
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public DateFormatter withZone(ZoneId zoneId) {
if (ZoneOffset.UTC.equals(zoneId) == false) {
throw new IllegalArgumentException(pattern() + " date formatter can only be in zone offset UTC");
}
return INSTANCE;
}
代码示例来源:origin: kousen/java_8_recipes
public static List<String> getRegionNamesForOffset(ZoneOffset offset) {
LocalDateTime now = LocalDateTime.now();
return ZoneId.getAvailableZoneIds().stream()
.map(ZoneId::of)
.filter(zoneId -> now.atZone(zoneId).getOffset().equals(offset))
.map(ZoneId::toString)
.sorted()
.collect(Collectors.toList());
}
代码示例来源:origin: com.github.seratch/java-time-backport
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof Fixed) {
return offset.equals(((Fixed) obj).offset);
}
if (obj instanceof StandardZoneRules) {
StandardZoneRules szr = (StandardZoneRules) obj;
return szr.isFixedOffset() && offset.equals(szr.getOffset(Instant.EPOCH));
}
return false;
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Checks if the specified offset is valid during this transition.
* <p>
* This checks to see if the given offset will be valid at some point in the transition.
* A gap will always return false.
* An overlap will return true if the offset is either the before or after offset.
*
* @param offset the offset to check, null returns false
* @return true if the offset is valid during the transition
*/
public boolean isValidOffset(ZoneOffset offset) {
return isGap() ? false : (getOffsetBefore().equals(offset) || getOffsetAfter().equals(offset));
}
代码示例来源:origin: com.github.seratch/java-time-backport
@Override
public boolean isDaylightSavings(Instant instant) {
return (getStandardOffset(instant).equals(getOffset(instant)) == false);
}
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Resolves the offset into this zoned date-time.
* <p>
* This ignores the offset, unless it can be used in an overlap.
*
* @param offset the offset, not null
* @return the zoned date-time, not null
*/
private ZonedDateTime resolveOffset(ZoneOffset offset) {
if (offset.equals(this.offset) == false && zone.getRules().isValidOffset(dateTime, offset)) {
return new ZonedDateTime(dateTime, offset, zone);
}
return this;
}
代码示例来源:origin: org.codehaus.groovy/groovy-datetime
/**
* Returns a generally equivalent {@link java.util.TimeZone}. The offset will be truncated to minutes.
*
* @param self a ZoneOffset
* @return a TimeZone
* @since 2.5.0
*/
public static TimeZone toTimeZone(final ZoneOffset self) {
if (ZoneOffset.UTC.equals(self)) {
return TimeZone.getTimeZone("GMT");
} else if (getSeconds(self) == 0) {
return TimeZone.getTimeZone("GMT" + self.getId());
} else {
// TimeZone is only hours and minutes--no seconds
ZoneOffset noSeconds = ZoneOffset.ofHoursMinutes(getHours(self), getMinutes(self));
return TimeZone.getTimeZone("GMT" + noSeconds.getId());
}
}
代码示例来源:origin: hprose/hprose-java
@Override
public final void serialize(Writer writer, OffsetTime time) throws IOException {
super.serialize(writer, time);
OutputStream stream = writer.stream;
if (!(time.getOffset().equals(ZoneOffset.UTC))) {
stream.write(TagString);
ValueWriter.write(stream, time.toString());
}
else {
ValueWriter.writeTime(stream, time.getHour(), time.getMinute(), time.getSecond(), 0, false, true);
ValueWriter.writeNano(stream, time.getNano());
stream.write(TagUTC);
}
}
}
代码示例来源:origin: org.hprose/hprose-java
@Override
public final void serialize(Writer writer, OffsetTime time) throws IOException {
super.serialize(writer, time);
OutputStream stream = writer.stream;
if (!(time.getOffset().equals(ZoneOffset.UTC))) {
stream.write(TagString);
ValueWriter.write(stream, time.toString());
}
else {
ValueWriter.writeTime(stream, time.getHour(), time.getMinute(), time.getSecond(), 0, false, true);
ValueWriter.writeNano(stream, time.getNano());
stream.write(TagUTC);
}
}
}
代码示例来源:origin: epam/DLab
private boolean areSchedulersEqualForSyncStarting(SchedulerJobDTO notebookScheduler,
SchedulerJobDTO clusterScheduler) {
return !Objects.isNull(notebookScheduler) && !Objects.isNull(clusterScheduler) &&
notebookScheduler.getBeginDate().equals(clusterScheduler.getBeginDate()) &&
notebookScheduler.getStartTime().equals(clusterScheduler.getStartTime()) &&
areCollectionsEqual(notebookScheduler.getStartDaysRepeat(), clusterScheduler.getStartDaysRepeat())
&& notebookScheduler.getTimeZoneOffset().equals(clusterScheduler.getTimeZoneOffset()) &&
notebookScheduler.isSyncStartRequired() && clusterScheduler.isSyncStartRequired();
}
代码示例来源:origin: com.github.seratch/java-time-backport
@Override
public ChronoZonedDateTime<D> withEarlierOffsetAtOverlap() {
ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this));
if (trans != null && trans.isOverlap()) {
ZoneOffset earlierOffset = trans.getOffsetBefore();
if (earlierOffset.equals(offset) == false) {
return new ChronoZonedDateTimeImpl<D>(dateTime, earlierOffset, zone);
}
}
return this;
}
代码示例来源:origin: com.github.seratch/java-time-backport
@Override
public ChronoZonedDateTime<D> withLaterOffsetAtOverlap() {
ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this));
if (trans != null) {
ZoneOffset offset = trans.getOffsetAfter();
if (offset.equals(getOffset()) == false) {
return new ChronoZonedDateTimeImpl<D>(dateTime, offset, zone);
}
}
return this;
}
内容来源于网络,如有侵权,请联系作者删除!