クライアントの到着日を文字列で取得し、それをパラメータとして strToCal メソッドに渡したいのですが、このメソッドはその日付の Calendar オブジェクトを返しますが、動作しません。id get parse exception エラー:
static String pattern = "yyyy-MM-dd HH:mm:ss";
System.out.println("enter arrival date ("+ pattern +"):\n" );
c.setArrDate(strToCal(sc.next(),c));
System.out.println("enter departure date ("+ pattern +"):\n");
c.setResTilDate(strToCal(sc.next(),c));
static Calendar strToCal(String s, Client c) throws ParseException {
try{
DateFormat df = new SimpleDateFormat(pattern);
Calendar cal = Calendar.getInstance();
cal.setTime(df.parse(s));
return cal;
} catch(ParseException e){
System.out.println("somethings wrong");
return null;
}