Code example for GregorianCalendar

Methods: clear

0
 
    public static Calendar parse(String str) throws ParseException {
        if (str == null) {
          return null; 
        } 
        Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
        cal.clear();
        int len = str.length();
        if (len == 0) { // empty string
            //TODO throw error? 
            return cal; 
        }         
        int i = 0;
        i = readYear(cal, str, i);
        i = readCharOpt('-', cal, str, i);
        if (i == -1) {
            return cal;
        } 
        i = readMonth(cal, str, i);
        i = readCharOpt('-', cal, str, i);
        if (i == -1) {