Server gives me time in this format:
Tue Jan 10 03:48:45 GMT+05:30 2017"
I want to convert it into:
Tue,Jan 2017"
I have searched google for a while now, still no luck. How can I do this?
Server gives me time in this format:
Tue Jan 10 03:48:45 GMT+05:30 2017"
I want to convert it into:
Tue,Jan 2017"
I have searched google for a while now, still no luck. How can I do this?
Following code will help you to convert one time format to another:
public static String formatDateFromOnetoAnother(String date) {
String resultformat = "EEE,MMM dd";
String givenformat = "EEE MMM dd zZ yyyy";
String result = "";
SimpleDateFormat sdf;
SimpleDateFormat sdf1;
try {
sdf = new SimpleDateFormat(givenformat);
sdf1 = new SimpleDateFormat(resultformat);
result = sdf1.format(sdf.parse(date));
} catch (Exception e) {
e.printStackTrace();
return "";
} finally {
sdf = null;
sdf1 = null;
}
return result;
}