- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中java.time.ZonedDateTime.toLocalDateTime()
方法的一些代码示例,展示了ZonedDateTime.toLocalDateTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTime.toLocalDateTime()
方法的具体详情如下:
包路径:java.time.ZonedDateTime
类名称:ZonedDateTime
方法名:toLocalDateTime
[英]Gets the LocalDateTime part of this date-time.
This returns a LocalDateTime with the same year, month, day and time as this date-time.
[中]获取此日期时间的LocalDateTime部分。
这将返回一个LocalDateTime,其年、月、日和时间与此日期时间相同。
代码示例来源:origin: spring-projects/spring-framework
@Override
public LocalDateTime convert(ZonedDateTime source) {
return source.toLocalDateTime();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public LocalDateTime convert(Calendar source) {
return calendarToZonedDateTime(source).toLocalDateTime();
}
}
代码示例来源:origin: org.springframework/spring-context
@Override
public LocalDateTime convert(ZonedDateTime source) {
return source.toLocalDateTime();
}
}
代码示例来源:origin: org.springframework/spring-context
@Override
public LocalDateTime convert(Calendar source) {
return calendarToZonedDateTime(source).toLocalDateTime();
}
}
代码示例来源:origin: Netflix/Priam
/**
* Convert date to LocalDateTime using system default zone.
*
* @param date Date to be transformed
* @return converted date to LocalDateTime
*/
public static LocalDateTime convert(Date date) {
if (date == null) return null;
return date.toInstant().atZone(defaultZoneId).toLocalDateTime();
}
代码示例来源:origin: zalando/zalenium
private static String dateTime(long epochMillis) {
DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
LocalDateTime date = Instant.ofEpochMilli(epochMillis).atZone(ZoneId.systemDefault()).toLocalDateTime();
return formatter.format(date);
}
代码示例来源:origin: apache/geode
private static LocalDateTime getEndTimeOf(Path file) {
try {
long lastModifiedMillis = file.toFile().lastModified();
return Instant.ofEpochMilli(lastModifiedMillis).atZone(ZoneId.systemDefault())
.toLocalDateTime();
} catch (Exception e) {
LOGGER.error("Unable to determine lastModified time", e);
return LocalDateTime.MAX;
}
}
代码示例来源:origin: apache/geode
public static LocalDateTime parseTime(String dateString) {
if (dateString == null) {
return null;
}
try {
SimpleDateFormat df = new SimpleDateFormat(ExportLogsCommand.FORMAT);
return df.parse(dateString).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
} catch (ParseException e) {
try {
SimpleDateFormat df = new SimpleDateFormat(ExportLogsCommand.ONLY_DATE_FORMAT);
return df.parse(dateString).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
} catch (ParseException e1) {
return null;
}
}
}
}
代码示例来源:origin: apache/nifi
private static LocalDateTime getLocalDateTimeFromEpochTime(String fieldName, Object coercedValue) {
Long date = DataTypeUtils.toLong(coercedValue, fieldName);
return Instant.ofEpochMilli(date).atZone(ZoneId.systemDefault()).toLocalDateTime();
}
代码示例来源:origin: org.mongodb/mongo-java-driver
@Override
public LocalDateTime decode(final BsonReader reader, final DecoderContext decoderContext) {
return Instant.ofEpochMilli(validateAndReadDateTime(reader)).atZone(ZoneOffset.UTC).toLocalDateTime();
}
代码示例来源:origin: jtablesaw/tablesaw
public static long pack(Date date) {
if (date == null) {
return missingValueIndicator();
}
return pack(date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
}
代码示例来源:origin: google/data-transfer-project
private void copyDateTime(
String key,
CalendarEventModel.CalendarEventTime dateTime,
Map<String, Object> graphCalendar) {
Map<String, String> graphDateTime = new HashMap<>();
graphDateTime.put(
"dateTime",
dateTime.getDateTime().atZoneSameInstant(ZoneId.of("UTC")).toLocalDateTime().toString());
graphDateTime.put("timeZone", "UTC");
graphCalendar.put(key, graphDateTime);
}
代码示例来源:origin: stackoverflow.com
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
public class DateUtils {
public static Date asDate(LocalDate localDate) {
return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
}
public static Date asDate(LocalDateTime localDateTime) {
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
}
public static LocalDate asLocalDate(Date date) {
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
}
public static LocalDateTime asLocalDateTime(Date date) {
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime();
}
}
代码示例来源:origin: confluentinc/ksql
public long parse(final String text, final ZoneId zoneId) {
TemporalAccessor parsed = formatter.parseBest(
text,
ZonedDateTime::from,
LocalDateTime::from);
if (parsed == null) {
throw new KsqlException("text value: "
+ text
+ "cannot be parsed into a timestamp");
}
if (parsed instanceof LocalDateTime) {
parsed = ((LocalDateTime) parsed).atZone(zoneId);
}
final LocalDateTime dateTime = ((ZonedDateTime) parsed)
.withZoneSameInstant(ZoneId.systemDefault())
.toLocalDateTime();
return Timestamp.valueOf(dateTime).getTime();
}
代码示例来源:origin: jtablesaw/tablesaw
/**
* Returns a DateTimeColumn where each value is the LocalDateTime represented by the values in this column
* <p>
* The values in this column must be longs that represent the time in milliseconds from the epoch as in standard
* Java date/time calculations
*
* @param offset The ZoneOffset to use in the calculation
* @return A column of LocalDateTime values
*/
public DateTimeColumn asDateTimes(ZoneOffset offset) {
DateTimeColumn column = DateTimeColumn.create(name() + ": date time");
for (int i = 0; i < size(); i++) {
column.append(Instant.ofEpochMilli(getLong(i)).atZone(offset).toLocalDateTime());
}
return column;
}
代码示例来源:origin: neo4j/neo4j
@Override
protected DateTimeValue selectDateTime( AnyValue datetime )
{
if ( datetime instanceof DateTimeValue )
{
DateTimeValue value = (DateTimeValue) datetime;
ZoneId zone = optionalTimezone();
return zone == null ? value : new DateTimeValue(
ZonedDateTime.of( value.temporal().toLocalDateTime(), zone ) );
}
if ( datetime instanceof LocalDateTimeValue )
{
return new DateTimeValue( ZonedDateTime.of(
((LocalDateTimeValue) datetime).temporal(), timezone() ) );
}
throw new UnsupportedTemporalUnitException( "Cannot select datetime from: " + datetime );
}
};
代码示例来源:origin: neo4j/neo4j
@Override
public boolean equals( Value other )
{
if ( other instanceof DateTimeValue )
{
ZonedDateTime that = ((DateTimeValue) other).value;
boolean res = value.toLocalDateTime().equals( that.toLocalDateTime() );
if ( res )
{
ZoneId thisZone = value.getZone();
ZoneId thatZone = that.getZone();
boolean thisIsOffset = thisZone instanceof ZoneOffset;
boolean thatIsOffset = thatZone instanceof ZoneOffset;
if ( thisIsOffset && thatIsOffset )
{
res = thisZone.equals( thatZone );
}
else if ( !thisIsOffset && !thatIsOffset )
{
res = TimeZones.map( thisZone.getId() ) == TimeZones.map( thatZone.getId() );
}
else
{
res = false;
}
}
return res;
}
return false;
}
代码示例来源:origin: apache/hive
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException {
if (arguments.length != 0) {
throw new UDFArgumentLengthException(
"The function CURRENT_TIMESTAMP does not take any arguments, but found "
+ arguments.length);
}
if (currentTimestamp == null) {
SessionState ss = SessionState.get();
ZonedDateTime dateTime = ss.getQueryCurrentTimestamp().atZone(
ss.getConf().getLocalTimeZone());
currentTimestamp = new TimestampWritableV2(
Timestamp.valueOf(dateTime.toLocalDateTime().toString()));
}
return PrimitiveObjectInspectorFactory.writableTimestampObjectInspector;
}
代码示例来源:origin: apache/hive
public static Timestamp stringToTimestamp(String s) {
s = s.trim();
// Handle simpler cases directly avoiding exceptions
if (s.length() == DATE_LENGTH) {
// Its a date!
return Timestamp.ofEpochMilli(Date.valueOf(s).toEpochMilli());
}
try {
return Timestamp.valueOf(s);
} catch (IllegalArgumentException eT) {
// Try zoned timestamp
try {
return Timestamp.valueOf(
TimestampTZUtil.parse(s).getZonedDateTime().toLocalDateTime().toString());
} catch (IllegalArgumentException | DateTimeParseException eTZ) {
// Last attempt
return Timestamp.ofEpochMilli(Date.valueOf(s).toEpochMilli());
}
}
}
}
代码示例来源:origin: neo4j/neo4j
@Override
public void writeDateTime( ZonedDateTime zonedDateTime ) throws IOException
{
long epochSecondLocal = zonedDateTime.toLocalDateTime().toEpochSecond( UTC );
int nano = zonedDateTime.getNano();
ZoneId zone = zonedDateTime.getZone();
if ( zone instanceof ZoneOffset )
{
int offsetSeconds = ((ZoneOffset) zone).getTotalSeconds();
packStructHeader( DATE_TIME_WITH_ZONE_OFFSET_SIZE, DATE_TIME_WITH_ZONE_OFFSET );
pack( epochSecondLocal );
pack( nano );
pack( offsetSeconds );
}
else
{
String zoneId = zone.getId();
packStructHeader( DATE_TIME_WITH_ZONE_NAME_SIZE, DATE_TIME_WITH_ZONE_NAME );
pack( epochSecondLocal );
pack( nano );
pack( zoneId );
}
}
}
在尝试 time 的 python 执行时,我发现在一条语句中两次调用 time.time() 时出现奇怪的行为。在语句执行期间获取time.time() 有一个非常小的处理延迟。 例如time.ti
我要疯了。对于我的生活,我无法弄清楚为什么以下代码会导致 Unity 在我按下播放键后立即卡住。这是一个空的项目,脚本附加到一个空的游戏对象。在控制台中,什么也没有出现,甚至没有出现初始的 Debug
我要疯了。对于我的生活,我无法弄清楚为什么以下代码会导致 Unity 在我按下播放键后立即卡住。这是一个空的项目,脚本附加到一个空的游戏对象。在控制台中,什么也没有出现,甚至没有出现初始的 Debug
我不明白为什么下面的结果是一样的。我预计第一个结果是指针地址。 func print(t *time.Time) { fmt.Println(t) // 2009-11-10 23:00:00
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32 Type "help
当我有一个time.Time时: // January, 29th t, _ := time.Parse("2006-01-02", "2016-01-29") 如何获得代表 1 月 31 日的 ti
首先,我意识到不推荐使用 time with time zone。我要使用它是因为我将多个 time with time zone 值与我当前的系统时间进行比较,而不管是哪一天。 IE。用户说每天 0
长期以来,在 Rust 中精确测量时间的标准方法是 time crate 及其 time::precise_time_ns功能。但是,time crate 现在已被弃用,std 库有 std::tim
我正在我学校的一个科学集群上运行我的有限差分程序。该程序使用 openmpi 来并行化代码。 当程序连续运行时,我得到: real 78m40.592s user 78m34.920s s
尽管它们已被弃用并且有比 time 更好的模块(即 timeit),但我想知道这两个函数 time 之间的区别.clock() 和 time.time()。 从后者 (time.time()) 开始,
这个问题在这里已经有了答案: Python's time.clock() vs. time.time() accuracy? (16 个答案) 关闭 6 年前。 我认为两者都衡量时间量?但是他们返回
我正在尝试测试 http 请求处理代码块在我的 Flask Controller 中需要多长时间,这是我使用的示例代码: cancelled = [] t0 = time.time() t1 = ti
运行 python 的计算机时钟(Windows 或 Linux)时会发生什么自动更改并调用 time.time()? 我读到,当时钟手动更改为过去的某个值时,time.time() 的值会变小。 最
我有一个结构可能无法在其字段之一上设置 time.Time 值。测试无效性时,我不能使用 nil 或 0。time.Unix(0,0) 也不相同。我想到了这个: var emptyTime time.
我有一个打算用数据库记录填充的结构,其中一个日期时间列可以为空: type Reminder struct { Id int CreatedAt time.Time
问题陈述:通过匹配其百分比随机执行各种命令。比如执行 CommandA 50% 的时间和 commandB 25% 的时间和 commandC 15% 的时间等等,总百分比应该是 100%。 我的问题
我正在使用 laravel 6。我在同一个应用程序中有类似的 Controller 和类似的 View ,它工作正常。对比之后还是找不到错误。 Facade\Ignition\Exceptions\V
我需要用 ("%m/%d/%Y %H:%M:%S") 格式表示时间,我得到的浮点值是 time.time(). 我已经有了一个 time.time() 形式的值。例如,我已经有一个值,我每 0.3 秒
我正在使用以下方法获取 utc 日期时间: import datetime import time from pytz import timezone now_utc = datetime.datet
我在 Ubuntu 上使用 time.clock 和 time.time 为一段 python 代码计时: clock elapsed time: 8.770 s time elapsed time
我是一名优秀的程序员,十分优秀!