简体   繁体   English

将日历添加到数据库后更改日期

[英]Change date after add calendar to database

When I try to add new time entry to my db application first days was changed and destroy hierarchy. 当我尝试向我的数据库应用程序添加新的时间条目时,第一天被更改并破坏层次结构。 First two days of my week was changed. 我的一周前两天改变了。

I try to change time zone from CET to UTC and CEST 我尝试将时区从CET更改为UTC和CEST

When I Post days from 25 - 31 days in DB return: 当我在DB返回时发布25 - 31天的天数:

2019-03-25
2019-03-25
2019-03-27
2019-03-28
2019-03-29
2019-03-30
2019-03-31

But next when I use postman to get this week it's return: 但接下来当我使用邮递员获得本周的回报时:

{

    "day": "SUNDAY",
    "date": "2019-03-24",
    "hours": 0,
    "status": "SAVED",
    "comment": ""
},
{
    "day": "SUNDAY",
    "date": "2019-03-24",
    "hours": 5,
    "status": "REJECTED",
    "comment": ""
},
{
    "day": "MONDAY",
    "date": "2019-03-25",
    "hours": 9,
    "status": "REJECTED",
    "comment": ""
},
{
    "day": "TUESDAY",
    "date": "2019-03-26",
    "hours": 9,
    "status": "SAVED",
    "comment": ""
},
{
    "day": "WEDNESDAY",
    "date": "2019-03-27",
    "hours": 9,
    "status": "SAVED",
    "comment": ""
},
{
    "day": "THURSDAY",
    "date": "2019-03-28",
    "hours": 9,
    "status": "SAVED",
    "comment": ""
},
{
    "day": "FRIDAY",
    "date": "2019-03-29",
    "hours": 9,
    "status": "SAVED",
    "comment": ""
}

My DB driver is : 我的DB驱动程序是:

DATABASE_URL=jdbc:mysql://localhost:3306/restdb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CET

Use the correct data types. 使用正确的数据类型。

DATE

In MySQL, your table column should be of type DATE . 在MySQL中,您的表列应为DATE类型。

This type is akin to the SQL-standard type DATE for date-only values without time-of-day and without time zone. 此类型类似于SQL标准类型DATE ,仅适用于没有时间且没有时区的仅限日期值。

LocalDate

Retrieve your date string value as a LocalDate , as shown on Stack Overflow many many times already. 将您的日期字符串值检索为LocalDate ,如Stack Overflow上所示已经多次显示。

The LocalDate class has no time zone, so you should see no adjustments. LocalDate类没有时区,因此您应该看不到任何调整。

LocalDate.parse( "2019-01-23" )

Or: 要么:

LocalDate ld = myResultSet.getObject( date_col , LocalDate.class ) ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM