【问题标题】:Angular Date time Spring boot LocalDateTime have wrong time, minus 5 hours and 30 minutesAngular Date time Spring boot LocalDateTime 有错误的时间,减去 5 小时 30 分钟
【发布时间】:2026-01-26 08:15:03
【问题描述】:

我在后端是 java spring boot 的 Angular 应用程序中使用primeng 日历。 在 java 中,时间错误

的日期正确出现
 <p-calendar formControlName="screeningDate" [maxDate]="today" dateFormat="dd/mm/yy"
                                        [showTime]="true" [hourFormat]="12" showButtonBar="true"></p-calendar>

和Java领域

private LocalDateTime screeningDate;

我在页面中选择了 05:48 PM 但在 restController @RequestBody 接收 12:18 (2022-01-10T12:18:09.318)

【问题讨论】:

    标签: spring-boot time calendar primeng localdatetime


    【解决方案1】:

    如果您的 Angular 应用程序将其与时区一起发送到后端,请尝试使用 ZonedDateTime。如果不明确,LocalDateTime 将在 JVM 或操作系统中配置的时区实例化日期。

    【讨论】:

    • 嗨,我试过 ZonedDateTime,但同样的问题
    最近更新 更多