-2

I have a time string in the following format 20170526T043000Z how can I convert it to milliseconds.

Saral Mohan
  • 328
  • 1
  • 12
  • Use `DateTimeFormatter` to parse the value to a `LocalDateTime` or `ZonedDateTime` from there you can get the millisecond values. Have a look at [Parsing and Formatting](https://docs.oracle.com/javase/tutorial/datetime/iso/format.html) for more details – MadProgrammer Apr 26 '17 at 05:50

1 Answers1

1

You can use SimpleDateFormat in java since you know the date format.

Eg:

String testDate = "20170526T043000Z";

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyymmdd'T'HHmmss");
Date parsedDate = simpleDateFormat.parse(testDate);
System.out.println("Time in millis " + parsedDate.getTime());
Uma Kanth
  • 5,659
  • 2
  • 20
  • 41
Stenal P Jolly
  • 737
  • 9
  • 20