Guest User

Untitled

a guest
Dec 12th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public String FormatCSTDate(String cstDateStr) {
  2. Date date = null;
  3. SimpleDateFormat sdf1 = null;
  4. SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  5. try {
  6. sdf1 = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.UK);
  7. date = sdf1.parse(cstDateStr);
  8. } catch (ParseException e) {
  9. sdf1 = new SimpleDateFormat("yyyy'年' MM'月' dd'日' EEE HH:mm:ss Z", Locale.CHINA);
  10. try {
  11. date = sdf1.parse(cstDateStr);
  12. } catch (ParseException e1) {
  13. System.out.println("CST日期格式转换出错,原因:" + e.getMessage());
  14. return null;
  15. }
  16. }
  17.  
  18. return sdf2.format(date);
  19. }
Add Comment
Please, Sign In to add comment