如何用Java中的模糊时区解析日期和时间?

我正在使用网络服务,对于巴西的弗洛里亚诺波利斯市,我得到以下日期:

2012年11月6日星期二,下午5:30

现在时区“LST”为SimpleDateFormat解析器创建了一个问题:

// Date to parse
String dateString = "Tue, 06 Nov 2012 5:30 pm LST";

// This parser works with other timezones
SimpleDateFormat LONG_DATE = new SimpleDateFormat("EEE, d MMM yyyy h:mm a zzz");

// Here it throws a ParseException
Date date = LONG_DATE.parse(dateString);

我知道时区很难解析.你有什么建议?

谢谢

最佳答案 试试这个

DateFormat gmtFormat = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");

TimeZone gmtTime = TimeZone.getTimeZone("GMT-02:00");
gmtFormat.setTimeZone(gmtTime);

System.out.println("Brazil :: " + gmtFormat.format(new Date()));
点赞