-1

I am receiving a timestamp like : 07/23/2019.08.45 from a system. I need to convert this to Epoch. I was not able to parse this format by using SimpleDateFormat.

I tried:

SimpleDateFormat SDF = new SimpleDateFormat("MM/dd/yyyy.HH:mm");
Date dateInstance =SDF.parse("07/23/2019.08.45");

but it didn't work

I also tried to split and parse the time and date but still got the unable to parse error

Can someone please help. What would be the most efficient way to get this done.

Sid
  • 1,224
  • 3
  • 23
  • 48
  • Possible duplicate of [Conversion of a date to epoch Java](https://stackoverflow.com/questions/49045682/conversion-of-a-date-to-epoch-java) – Ryuzaki L Sep 18 '19 at 14:58
  • Don't use `SimpleDateFormat`, that class is notoriously troublesome and long outdated. Use java.time and its `DateTimeFormatter`. – Ole V.V. Sep 18 '19 at 18:41
  • What error are you getting? Please quote any error message verbatim. If you get an exception, paste the stacktrace and format it as code for readability. – Ole V.V. Sep 18 '19 at 18:42

1 Answers1

2

You are not providing the correct date format:

SimpleDateFormat SDF = new SimpleDateFormat("MM/dd/yyyy.HH:mm");
Date dateInstance =SDF.parse("07/23/2019.08:45");

Notice : instead of .

Prashant
  • 4,775
  • 3
  • 28
  • 47