本文整理了Java中org.threeten.bp.ZoneId.systemDefault()
方法的一些代码示例,展示了ZoneId.systemDefault()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneId.systemDefault()
方法的具体详情如下:
包路径:org.threeten.bp.ZoneId
类名称:ZoneId
方法名:systemDefault
[英]Gets the system default time-zone.
This queries TimeZone#getDefault() to find the default time-zone and converts it to a ZoneId. If the system default time-zone is changed, then the result of this method will also change.
[中]获取系统默认时区。
查询时区#getDefault()以查找默认时区并将其转换为ZoneId。如果更改了系统默认时区,则此方法的结果也将更改。
代码示例来源:origin: org.threeten/threetenbp
/**
* Obtains a clock that returns the current instant using the best available
* system clock, converting to date and time using the default time-zone.
* <p>
* This clock is based on the best available system clock.
* This may use {@link System#currentTimeMillis()}, or a higher resolution
* clock if one is available.
* <p>
* Using this method hard codes a dependency to the default time-zone into your application.
* It is recommended to avoid this and use a specific time-zone whenever possible.
* The {@link #systemUTC() UTC clock} should be used when you need the current instant
* without the date or time.
* <p>
* The returned implementation is immutable, thread-safe and {@code Serializable}.
* It is equivalent to {@code system(ZoneId.systemDefault())}.
*
* @return a clock that uses the best available system clock in the default zone, not null
* @see ZoneId#systemDefault()
*/
public static Clock systemDefaultZone() {
return new SystemClock(ZoneId.systemDefault());
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Obtains a clock that returns the current instant using the best available
* system clock, converting to date and time using the default time-zone.
* <p>
* This clock is based on the best available system clock.
* This may use {@link System#currentTimeMillis()}, or a higher resolution
* clock if one is available.
* <p>
* Using this method hard codes a dependency to the default time-zone into your application.
* It is recommended to avoid this and use a specific time-zone whenever possible.
* The {@link #systemUTC() UTC clock} should be used when you need the current instant
* without the date or time.
* <p>
* The returned implementation is immutable, thread-safe and {@code Serializable}.
* It is equivalent to {@code system(ZoneId.systemDefault())}.
*
* @return a clock that uses the best available system clock in the default zone, not null
* @see ZoneId#systemDefault()
*/
public static Clock systemDefaultZone() {
return new SystemClock(ZoneId.systemDefault());
}
代码示例来源:origin: XeroAPI/Xero-Java
public OffsetDateTime deserialize(JsonParser jsonparser, DeserializationContext context)
throws IOException, JsonProcessingException {
String date = jsonparser.getText();
OffsetDateTime formattedDate;
Pattern datePatt = Pattern.compile("^/Date\\((\\d+)([+-]\\d+)?\\)/$");
Matcher m = datePatt.matcher(date);
if (m.matches()) {
Long l = Long.parseLong(m.group(1));
formattedDate = Instant.ofEpochMilli(l).atZone(ZoneId.systemDefault()).toOffsetDateTime();
} else {
throw new IllegalArgumentException("Wrong date format");
}
return formattedDate;
}
}
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public LocalDateTime convert(Date source) {
return ofInstant(toInstant(source), systemDefault());
}
}
代码示例来源:origin: XeroAPI/Xero-Java
public LocalDate deserialize(JsonParser jsonparser, DeserializationContext context)
throws IOException, JsonProcessingException {
String date = jsonparser.getText();
LocalDate formattedDate;
Pattern datePatt = Pattern.compile("^/Date\\((\\d+)([+-]\\d+)?\\)/$");
Matcher m = datePatt.matcher(date);
if (m.matches()) {
Long l = Long.parseLong(m.group(1));
formattedDate = Instant.ofEpochMilli(l).atZone(ZoneId.systemDefault()).toLocalDate();
} else {
throw new IllegalArgumentException("Wrong date format");
}
return formattedDate;
}
}
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public LocalTime convert(Date source) {
return ofInstant(ofEpochMilli(source.getTime()), systemDefault()).toLocalTime();
}
}
代码示例来源:origin: jeffdcamp/dbtools-android
@Nullable
public static Long localDateTimeToLong(@Nullable LocalDateTime d) {
if (d == null) {
return null;
}
return d.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
}
代码示例来源:origin: jeffdcamp/dbtools-android
@Nullable
public static LocalDateTime longToLocalDateTime(@Nullable Long l) {
if (l == null) {
return null;
}
return Instant.ofEpochMilli(l).atZone(ZoneId.systemDefault()).toLocalDateTime();
}
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public LocalDate convert(Date source) {
return ofInstant(ofEpochMilli(source.getTime()), systemDefault()).toLocalDate();
}
}
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public Date convert(LocalDateTime source) {
return toDate(source.atZone(systemDefault()).toInstant());
}
}
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public Date convert(LocalDate source) {
return toDate(source.atStartOfDay(systemDefault()).toInstant());
}
}
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public Date convert(Instant source) {
return toDate(source.atZone(systemDefault()).toInstant());
}
}
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public java.time.LocalDateTime convert(LocalDateTime source) {
Date date = toDate(source.atZone(ZoneId.systemDefault()).toInstant());
return Jsr310Converters.DateToLocalDateTimeConverter.INSTANCE.convert(date);
}
}
代码示例来源:origin: Krillsson/sys-API
default java.util.Date map(org.threeten.bp.LocalDate value) {
return value != null ? DateTimeUtils.toDate(value.atStartOfDay(ZoneId.systemDefault()).toInstant()) : null;
}
}
代码示例来源:origin: riggaroo/android-things-electricity-monitor
private Duration getDifferenceBetweenTimeAndNow(long timeStart) {
LocalDateTime today = LocalDateTime.now();
LocalDateTime otherTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeStart), ZoneId.systemDefault());
return Duration.between(otherTime, today);
}
代码示例来源:origin: gabrielittner/lazythreetenbp
/**
* Call on background thread to eagerly load all zones. Starts with loading
* {@link ZoneId#systemDefault()} which is the one most likely to be used.
*/
@WorkerThread
public static void cacheZones() {
ZoneId.systemDefault().getRules();
for (String zoneId : ZoneRulesProvider.getAvailableZoneIds()) {
ZoneRulesProvider.getRules(zoneId, true);
}
}
代码示例来源:origin: apache/servicemix-bundles
@Nonnull
@Override
public Date convert(LocalTime source) {
return toDate(source.atDate(LocalDate.now()).atZone(systemDefault()).toInstant());
}
}
内容来源于网络,如有侵权,请联系作者删除!