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!!
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!!
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)