OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 80 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 80 Rev 180
Line 83... Line 83...
83
        @Override
83
        @Override
84
        public Object parse(String s) {
84
        public Object parse(String s) {
85
            return FLOAT.parse(s);
85
            return FLOAT.parse(s);
86
        }
86
        }
87
    },
87
    },
-
 
88
    // TODO support LocalDateTime
88
    DATE("date-value", Date.class, Calendar.class) {
89
    DATE("date-value", Date.class, Calendar.class) {
89
 
90
 
90
        @Override
91
        @Override
91
        public String format(Object o) {
92
        public String format(Object o) {
92
            return formatDate(o);
93
            return formatDate(o);
Line 104... Line 105...
104
                }
105
                }
105
            }
106
            }
106
        }
107
        }
107
 
108
 
108
    },
109
    },
109
    TIME("time-value", Duration.class, Calendar.class) {
110
    TIME("time-value", Duration.class, java.time.Duration.class, Calendar.class) {
110
 
111
 
111
        @Override
112
        @Override
112
        public String format(Object o) {
113
        public String format(Object o) {
113
            if (o instanceof Duration) {
114
            if (o instanceof Duration) {
114
                return o.toString();
115
                return o.toString();
-
 
116
            } else if (o instanceof java.time.Duration) {
-
 
117
                // w/o days or larger : PTnHnMnS
-
 
118
                return o.toString();
115
            } else {
119
            } else {
116
                final Calendar cal = (Calendar) o;
120
                final Calendar cal = (Calendar) o;
117
                return TimeUtils.timePartToDuration(cal).toString();
121
                return TimeUtils.timePartToDuration(cal).toString();
118
            }
122
            }
119
        }
123
        }
Line 216... Line 220...
216
            return FLOAT;
220
            return FLOAT;
217
        else if (o instanceof Boolean)
221
        else if (o instanceof Boolean)
218
            return BOOLEAN;
222
            return BOOLEAN;
219
        else if (o instanceof String)
223
        else if (o instanceof String)
220
            return STRING;
224
            return STRING;
221
        else if (o instanceof Duration)
225
        else if (o instanceof Duration || o instanceof java.time.Duration)
222
            return TIME;
226
            return TIME;
223
        else if (DATE.canFormat(o.getClass()))
227
        else if (DATE.canFormat(o.getClass()))
224
            return DATE;
228
            return DATE;
225
        else
229
        else
226
            return null;
230
            return null;