Convert a string to a GregorianCalendar
问题 How do a I take an input birthday string such as 02 26 1991 and make it into a Gregorian Calendar? I tried parsing it first but it keeps giving me an error message so I\'m not quite sure what I\'m doing wrong. I also have other input data before this date. One is another string and one is a double value. 回答1: Use SimpleDateFormat to parse the date and then assign it to a Calendar. DateFormat df = new SimpleDateFormat("dd MM yyyy"); Date date = df.parse("02 26 1991"); Calendar cal = Calendar