Here you can find the source of parse(String dateText)
Parameter | Description |
---|---|
dateText | The date as a String. |
public static Calendar parse(String dateText)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { /**// www . ja v a 2s. c o m * Default date format in the form 2013-03-18. */ private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); /** * Converst a String in the format "yyyy-MM-dd" to a Calendar object. * Returns null if the String could not be converted. * * @param dateText The date as a String. * @return The calendar object, or null if it could not be converted. */ public static Calendar parse(String dateText) { try { Calendar result = Calendar.getInstance(); result.setTime(DATE_FORMAT.parse(dateText)); return result; } catch (NullPointerException | ParseException e) { return null; } } }