Java parse converts a date string with English words to a date string (converted to the time returned by Sina Weibo API)

Source: Internet
Author: User
Generally, it is seldom formatted or parse strings with English words such as Sun Nov. If you format the string of the English month, remember to include the locale. Us parameter. Otherwise, the JRE will be interpreted according to the language format of the current region, and an error will occur.

 

 string a = "Sun Nov 13 21:56:41 + 0800 2011"; 
simpledateformat SDF = New simpledateformat (" eee Mmm dd hh: mm: ss z yyyy ", locale. US); /// Mmm dd hh: mm: ss z yyyy
try {< br> system. out. println (SDF. parse (a);
}< span style = "color: # 0000ff;"> catch (parseexception ex) {
logger. getlogger (javaapplication1. class . getname ()). log (level. severe, null , ex);
}


For details, refer: Http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html#text
Http://www.cnblogs.com/luyubin/archive/2009/03/17/1414086.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.