Code example for Matcher

Methods: findgroup

0
        if(StringUtils.isEmpty(text)) {
            return 0; 
        } 
         
        Matcher m = dateTextPattern.matcher(text);
        if(!m.find()) {
            return 0; 
        } 
         
        int day = Integer.valueOf(m.group(1));
        String monthStr = m.group(2);
        int monthIndex = Arrays.asList(sMonthNames).indexOf(monthStr);
        int month = monthIndex != -1 ? monthIndex : 0;
        int year = Integer.valueOf(m.group(3));
        int hour = Integer.valueOf(m.group(4));
        int minute = Integer.valueOf(m.group(5));
        int second = Integer.valueOf(m.group(6));
 
        Date date  = new Date(year - 1900, month, day, hour, minute, second);
         
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
Stop searching for code, let great code find you!  Add Codota to your java IDE