Here you can find the source of parse(String source)
Parameter | Description |
---|---|
source | the formatted String to parse |
public static Calendar parse(String source) throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { private static DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); /**/*from w w w . j av a2 s . c om*/ * Null-safe method to create a {@link Calendar} from a formatted {@link String}. * <p/> * Format template is {@code yyyy-MM-dd'T'HH:mm:ss}. * * @param source the formatted {@link String} to parse * @return a {@link Calendar} */ public static Calendar parse(String source) throws ParseException { Calendar cal = Calendar.getInstance(); cal.setTime(df.parse(source)); return cal; } }