Revision 44750 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/function/date/TimeFunction.java

View differences:

TimeFunction.java
11 11
public class TimeFunction extends AbstractFunction {
12 12

  
13 13
    public TimeFunction() {
14
        super("Date", FUNCTION_TIME,Range.between(1,2),
14
        super("Date", FUNCTION_TIME,Range.is(1),
15 15
            "Returns a time from the arguments",
16
            FUNCTION_TIME+"({{time}}, format)",
16
            FUNCTION_TIME+"({{time}})",
17 17
            new String[]{
18
                "time - a string with a time",
19
                "format - Optional. Format to use to parse the time"
18
                "time - a string with a time"
20 19
            },
21 20
            "Time"
22 21
        );
......
38 37
            return x;
39 38
        }
40 39
        String date = getStr(args, 0);
41
        String format = null;
42
        if( args.length==2 ) {
43
            format = getStr(args, 1);
44
        }
45
        SimpleDateFormat df = new SimpleDateFormat();
46
        if( format != null ) {
47
            df.applyPattern(format);
48
        }
40
        SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
49 41
        try {
50 42
            Date x = df.parse(date);
51 43
            x.setDate(0);
......
53 45
            x.setYear(0);
54 46
            return x;
55 47
        } catch (ParseException ex) {
56
            throw new RuntimeException("Can't parse date value '"+date+"' with format '"+format==null?"":format+"'", ex);
48
            throw new RuntimeException("Can't parse time value '"+date+"' expected format 'HH:mm:ss'.", ex);
57 49
        }
58 50
        
59 51
    }

Also available in: Unified diff