Here you can find the source of parse(String dateStr)
Parameter | Description |
---|---|
dateStr | a string representing a date |
public static Date parse(String dateStr)
import android.util.Log; import com.archee.picturedownloader.PictureDownloader; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main{ public static final SimpleDateFormat DEFAULT_FORMATTER = new SimpleDateFormat( DEFAULT_FORMAT);/*from w w w . j a v a 2 s.co m*/ /** * Converts the given string into a java.util.Date object using the defined default format yyyy-MM-dd HH:mm * @param dateStr a string representing a date * @return the Date object created from the date string, or null if format incorrect. */ public static Date parse(String dateStr) { Date parsedDate; try { parsedDate = DEFAULT_FORMATTER.parse(dateStr); } catch (ParseException e) { Log.e(PictureDownloader.TAG, "Error parsing date string: " + dateStr + " - returning current date..."); parsedDate = new Date(); } return parsedDate; } }