Reputation: 9194
I am having an issue trying to parse a date using java.time.LocalDateTime.parse. I am sure that it is something silly that I am completely overlooking, but cannot for the life of me figure it out. If the date string does not have a "Z" at the end it works fine, but if it does it will fail during the parse.
Was referencing: DateTimeFormatter
Code:
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
class GroovyPrintExample {
static void main(String[] args) {
def formatter = DateTimeFormatter.ISO_INSTANT
def test = "2015-11-12T14:11:03.354Z"
def dateTime = LocalDateTime.parse(test, formatter)
}
}
Upvotes: 1
Views: 565
Reputation: 800
The Z is for timezone, right? Have you tried using ZonedDateTime instead?
Upvotes: 1