Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZonedDateTime with Zulu or GMT0 timezone is unparsable from string? #681

Open
liamjones opened this issue Apr 17, 2023 · 1 comment
Open
Labels

Comments

@liamjones
Copy link
Contributor

This seems like a bug? js-joda is quite happy to construct a ZonedDateTime with the Zulu or GMT0 timezones and convert it to a string but unable to re-parse it from the same string output?

import {ZonedDateTime, LocalDateTime, ZoneId} from '@js-joda/core'
import '@js-joda/timezone'

console.log('start')
const now = LocalDateTime.now()
for(const zoneId of ZoneId.getAvailableZoneIds()) {
  const date = ZonedDateTime.of(now, ZoneId.of(zoneId))
  const dateString = date.toString()
  try {
    ZonedDateTime.parse(dateString)
  } catch(e) {
    console.error(e)
  }
}
console.log('end')

Output:

start 
DateTimeParseException: Text '2023-04-17T14:25:43.635Z[GMT0]' could not be parsed, unparsed text found at index 24: 2023-04-17T14:25:43.635Z[GMT0], at index: 24
DateTimeParseException: Text '2023-04-17T14:25:43.635Z[Zulu]' could not be parsed, unparsed text found at index 24: 2023-04-17T14:25:43.635Z[Zulu], at index: 24
end 
@pithu
Copy link
Member

pithu commented Apr 17, 2023

@liamjones Thanks for reporting. Yes looks like a bug.

@pithu pithu added the bug label Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants