0

I get a time string like "Thu, 11 Aug 2016 00:33:30 GMT".And I want to convert it to a Date object in Java. I do it with the code:

String timeString= "Thu, 11 Aug 2016 00:33:30 GMT";
SimpleDateFormat inputFormat = new SimpleDateFormat
        ("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.CHINA);
inputFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date= null;
    try {
        date = inputFormat.parse(timeString);
        System.out.println(date.toString());
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

But I got a "java.text.ParseException: Unparseable date: 'Thu, 11 Aug 2016 00:33:30 GMT'" exception. Is everyone know why?Thanks a lot...

Raman Sahasi
  • 30,180
  • 9
  • 58
  • 71
Ruben
  • 405
  • 1
  • 4
  • 5

1 Answers1

1

The problem is with Locale.CHINA. Aug is not in China language and changing it to Locale.ENGLISH will solve the problem.

ByeBye
  • 6,650
  • 5
  • 30
  • 63