You're using hh
, which is the 12-hour clock. You want to use HH
instead:
"yyyy-MM-dd'T'HH:mm:ss"
From the docs for SimpleDateFormat
- hh - Hour in am/pm (1-12)
- HH - Hour in day (0-23)
- kk - Hour in day (1-24)
- KK - Hour in am/pm (0-11)
(Quite why they reversed the capitalization in terms of 12/24 hours for kk
/KK
is beyond me, but then the whole of the Java date/time API is crazy...)
Also, while it looks like you're currently okay, it's worth thinking about the time zone aspect. A Date
doesn't have any concept of a time zone or calendar - it's just an instant in time. The SimpleDateFormat
does have an associated time zone and calendar (and culture) so make sure they're correct for your purposes.