-2

First i have written the Calender instance getTime method value to a file. now by reading the file i want to set that value as date object?

Format of the data written to the file

Wed Mar 29 18:54:53 IST 2017

How can i do that?

Thanks!!

JAVA
  • 524
  • 11
  • 23
  • See `SimpleDateFormat` (https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html) and please look in SO, there are many examples – Jérôme Mar 28 '17 at 14:54

1 Answers1

1

Check out the the class SimpleDateFormat: https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html

This should work for your example:

String inputString = "Wed Mar 29 18:54:53 IST 2017";
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
sdf.parse(inputString)
saidaspen
  • 560
  • 1
  • 5
  • 13