question: private Calendar parseCalendar ( String string ) throws ParseException { Calendar cal = new GregorianCalendar ( TimeZone . getTimeZone ( "GMT" ) ) ; SimpleDateFormat sdf2 = new SimpleDateFormat ( "dd.MM.yy" ) ; SimpleDateFormat sdf4 = new SimpleDateFormat ( "dd.MM.yyyy" ) ; sdf2 . setLenient ( false ) ; sdf4 . setLenient ( false ) ; Date date ; try { date = sdf2 . parse ( string ) ; } catch ( ParseException e ) { date = sdf4 . parse ( string ) ; } cal . setTime ( date ) ; return cal ; }
target:  Accepts both dd.MM.yy and dd.MM.yyyy formats