Here you can find the source of getCalenderFromDateString(String dateString)
Parameter | Description |
---|---|
dateString | a parameter |
public static Calendar getCalenderFromDateString(String dateString)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main { /**//from ww w .java2 s . c o m * H: 00-23, h: 0-11(am/pm) Z: timezone (+8000) see full doc <a href= * "http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html" * >docs.oracle.com</a>. Locale.US is always available on all platform (see * Locale javadoc) */ private static final java.text.DateFormat weiboCreateDateFormat = new SimpleDateFormat( "EEE MMM dd HH:mm:ss Z yyyy", Locale.US); /** * parse Date string like: "Sat Sep 21 23:39:40 +0800 2013" to * java.util.Date object * * @param dateString * @return Calendar representation or epoch if parse error */ public static Calendar getCalenderFromDateString(String dateString) { Calendar cal = Calendar.getInstance(); try { cal.setTime(weiboCreateDateFormat.parse(dateString)); } catch (ParseException e) { cal.setTime(new Date(0)); } return cal; } }