Closed mark-mngoma closed 2 years ago
@NtsikaMngoma : thanks for reporting this issue. But I suppose it's the same ticket than https://github.com/jhipster/generator-jhipster/issues/11740, that's why I'm closing this
You shouldn't close it, as this is not the same bug. This bug is only happening on the client application, when testing on Postman, there's no issue.
My workaround on the client was to set a datePicker value and use ngbDatepicker to select the date ontoggle, otherwise with all projects that I have tested, only when POSTING from the client the wrong date is persisted.
If you can fix that the jhipster way, it would be great. I am assuming the problem is either date parsing with moment or with your datepicker-adapter in utils.
@NtsikaMngoma : can you fill the template, so we can know your exact configuration plz ? Just use jhipster info
@NtsikaMngoma : can you fill the template, so we can know your exact configuration plz ? Just use
jhipster info
.yo-rc.json
file generated in the root folder{ "generator-jhipster": { "baseName": "jhipsterDtoSampleApplication", "packageName": "io.github.jhipster.sample", "packageFolder": "io/github/jhipster/sample", "authenticationType": "session", "hibernateCache": "ehcache", "clusteredHttpSession": false, "websocket": false, "databaseType": "sql", "devDatabaseType": "h2Memory", "prodDatabaseType": "mysql", "searchEngine": false, "useCompass": false, "buildTool": "maven", "enableTranslation": true, "applicationType": "monolith", "testFrameworks": [ "gatling", "protractor" ], "languages": [ "en" ], "serverPort": 8080, "jhipsterVersion": "6.9.0", "enableSocialSignIn": false, "rememberMeKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons", "useSass": true, "jhiPrefix": "jhi", "messageBroker": false, "serviceDiscoveryType": false, "clientPackageManager": "npm", "clientFramework": "angularX", "cacheProvider": "ehcache", "enableHibernateCache": true, "reactive": false, "otherModules": [], "entitySuffix": "", "dtoSuffix": "DTO", "clientTheme": "none", "blueprints": [], "embeddableLaunchScript": false, "creationTimestamp": 1577001241660 }, "generator-jhipster-flutter-merlin": { "promptValues": { "baseName": "jhipster-flutter", "packageName": "com.myapp", "android": "java", "ios": "swift", "stateManageType": "bloc" } } }
entityName.json
files generated in the .jhipster
directoryentity BankAccount { name String required, balance BigDecimal required } entity Label { label String required minlength(3) } entity Operation { date DateTime required, description String, amount BigDecimal required } relationship OneToMany { BankAccount{operation} to Operation{bankAccount(name)} } relationship ManyToOne { BankAccount{user(login)} to User } relationship ManyToMany { Operation{label(label)} to Label{operation} } dto BankAccount, Label, Operation with mapstruct paginate Operation with infinite-scroll
java version "1.8.0_211" Java(TM) SE Runtime Environment (build 1.8.0_211-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
git version 2.27.0.windows.1
node: v12.16.3
npm: 6.14.4
yeoman: 3.1.1
yarn: 1.22.4
Docker version 19.03.1, build 74b1e89e8a
docker-compose version 1.24.1, build 4667896b
identical .jhipster\BankAccount.json identical .jhipster\Label.json identical .jhipster\Operation.json INFO! Congratulations, JHipster execution is complete!
This issue is stale because it has been open 30 days with no activity. Our core developers tend to be more verbose on denying. If there is no negative comment, possibly this feature will be accepted. We are accepting PRs :smiley:. Comment or this will be closed in 7 days
We migrate from moments to days in generator main branch. @NtsikaMngoma Can you confirm the issue is fixed and can be closed?
this issue is caused by .toJSON()
that decrease the specified date. I propose to replace it by .format()
method as follow: dayjs(entity.date).format('YYYY-MM-DDTHH:mm:00.000Z')
#13024
I think that the current implementation is correct. If user current timezone is +02:00 then correct UTC value of Sep 23, 2020, 12:00:00 AM
is 2020-09-22T22:00:00.000Z
as it is sent to back end.
But in database can be saved wrong values with the reasons highlighted below.
Database related configs are setting timezone to UTC:
serverTimezone=UTC
(this is written to application-dev.yml
and to application-prod.yml
): https://github.com/jhipster/generator-jhipster/blob/main/generators/generator-base-private.js#L1265hibernate.jdbc.time_zone: UTC
: https://github.com/jhipster/generator-jhipster/blob/master/generators/server/templates/src/main/resources/config/application.yml.ejs#L213MySql default config is using system timezone, which seems to be in this case +02:00, so this results wrong datetimes to be saved into database with default config. 2 solutions here:
H2 database uses JVM timezone which by default is also system timezone, so also in H2 there are wrong datetimes saved if user current timezone is +02:00. Here also 2 solutions:
hibernate.jdbc.time_zone: UTC
from https://github.com/jhipster/generator-jhipster/blob/master/generators/server/templates/src/main/resources/config/application.yml.ejs#L213Is ZonedDateTime the java type that is used after your JDL import ? (I tried to import your jdl, but it says that DateTime is an unknown field..).
1)
If it is ZonedDateTime:
Your issue may be related to this improvement: https://github.com/jhipster/generator-jhipster/issues/12262
Because with the current implementation there is no data storing the zone
.
2) If it is a LocalDate (as mentioned in the ticket):
Run any jdl with LocalDate and save on entity to see the issue.
It's strange as this should be fixed by https://github.com/jhipster/generator-jhipster/issues/11740
3) If it is an Instant: I would say it's not an issue but it's not the type you actually need.
This issue is stale because it has been open 30 days with no activity. Our core developers tend to be more verbose on denying. If there is no negative comment, possibly this feature will be accepted. We are accepting PRs :smiley:. Comment or this will be closed in 7 days
Overview of the issue
As I select the date as 2020-09-23, the response payload gives 2020-09-22 which is yesterdays date and is incorrect.
Motivation for or Use Case
The date entered on the client application should match the date saved in the db and returned on the API response.
Reproduce the error
Run any jdl with LocalDate and save on entity to see the issue.
Related issues
Suggest a Fix
I am assuming this is an issue with moment and how it's parsed as the way the date is persisting is confusing to understand and also hard to debug on the client application. When I POST on swagger/postman there's no problem. Thee issue starts when I am interacting on the client.
JHipster Version(s)
This is the latest 6.10 jhipster version