I am not sure whether this has been already answered or not, but can anyone please tell me how can I convert "2019-07-14T18:30:00.000Z" to "2019-07-14 04:30:00 PM" using DateTimeFormatter or any other library in Java? Basically the output date-time should have time in AM/PM format.
Try this
String date = "2019-07-14T18:30:00.000Z";
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
Date parsedDate = inputFormat.parse(date);
String formattedDate = outputFormat.format(parsedDate);
System.out.println(formattedDate);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With