How to parse the following timestamp in string formate to date formate.
Mon Sep 25 13:40:56 GMT+05:30 2017
Since it has GMT in the timestamp so I didn't find a valid answer for this. Please let me know how to write SimpleDateFormat
for this?
How to parse the following timestamp in string formate to date formate.
Mon Sep 25 13:40:56 GMT+05:30 2017
Since it has GMT in the timestamp so I didn't find a valid answer for this. Please let me know how to write SimpleDateFormat
for this?
in java 7 with SimpleDateFormat
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Test {
public static void main(String[] args) {
String input = "Mon Sep 25 13:40:56 GMT+05:30 2017";
String dateFormat = "EEE MMM d HH:mm:ss z yyyy";
try {
Date date = new SimpleDateFormat(dateFormat).parse(input);
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
}
}
}
See it in action : https://ideone.com/RaCugz