本文整理了Java中org.threeten.bp.ZonedDateTime.toInstant()
方法的一些代码示例,展示了ZonedDateTime.toInstant()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTime.toInstant()
方法的具体详情如下:
包路径:org.threeten.bp.ZonedDateTime
类名称:ZonedDateTime
方法名:toInstant
暂无
代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp
@Override
public long applyAsLong(ZonedDateTime dt) {
return dt.toInstant().toEpochMilli();
}
},
代码示例来源:origin: Ullink/simple-slack-api
private String convertDateToSlackTimestamp(ZonedDateTime date) {
return (date.toInstant().toEpochMilli() / 1000) + ".123456";
}
代码示例来源: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: apache/servicemix-bundles
@Nonnull
@Override
public java.time.Instant convert(LocalDateTime source) {
return java.time.Instant.ofEpochMilli(source.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli());
}
}
代码示例来源: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: apache/servicemix-bundles
@Nonnull
@Override
public Date convert(LocalTime source) {
return toDate(source.atDate(LocalDate.now()).atZone(systemDefault()).toInstant());
}
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Converts a {@code ZonedDateTime} to a {@code Calendar}.
* <p>
* The resulting {@code GregorianCalendar} is pure Gregorian and uses
* ISO week definitions, starting on Monday and with 4 days in a minimal week.
* <p>
* Fractions of the instant smaller than milliseconds will be dropped.
*
* @param zdt the zoned date-time, not null
* @return the calendar, not null
* @throws IllegalArgumentException if the conversion fails
*/
public static GregorianCalendar toGregorianCalendar(ZonedDateTime zdt) {
TimeZone zone = toTimeZone(zdt.getZone());
GregorianCalendar cal = new GregorianCalendar(zone);
cal.setGregorianChange(new Date(Long.MIN_VALUE));
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.setMinimalDaysInFirstWeek(4);
try {
cal.setTimeInMillis(zdt.toInstant().toEpochMilli());
} catch (ArithmeticException ex) {
throw new IllegalArgumentException(ex);
}
return cal;
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Converts a {@code ZonedDateTime} to a {@code Calendar}.
* <p>
* The resulting {@code GregorianCalendar} is pure Gregorian and uses
* ISO week definitions, starting on Monday and with 4 days in a minimal week.
* <p>
* Fractions of the instant smaller than milliseconds will be dropped.
*
* @param zdt the zoned date-time, not null
* @return the calendar, not null
* @throws IllegalArgumentException if the conversion fails
*/
public static GregorianCalendar toGregorianCalendar(ZonedDateTime zdt) {
TimeZone zone = toTimeZone(zdt.getZone());
GregorianCalendar cal = new GregorianCalendar(zone);
cal.setGregorianChange(new Date(Long.MIN_VALUE));
cal.setFirstDayOfWeek(Calendar.MONDAY);
cal.setMinimalDaysInFirstWeek(4);
try {
cal.setTimeInMillis(zdt.toInstant().toEpochMilli());
} catch (ArithmeticException ex) {
throw new IllegalArgumentException(ex);
}
return cal;
}
内容来源于网络,如有侵权,请联系作者删除!