farshad farshad - 13 days ago 5
Android Question

how to convert GMT to Local date time in android

I have a time like this : Thu, 27 Oct 2016 18:17:47 GMT

I have tried the code bellow but didn't work

String inputText = "Thu, 27 Oct 2016 18:17:47 GMT";
SimpleDateFormat inputFormat = new SimpleDateFormat
("EEE MMM dd HH:mm:ss 'GMT' yyyy", Locale.US);

SimpleDateFormat outputFormat =
new SimpleDateFormat("MMM dd, yyyy h:mm a");
// Adjust locale and zone appropriately
Date date = inputFormat.parse(inputText);
String outputText = outputFormat.format(date);


Your input date and input format don't match each other. Try this input format instead:

SimpleDateFormat inputFormat = new SimpleDateFormat
    ("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);