private static final Logger logger = Logger.getLogger(TSqlIndex.class);
public static final String TAG = "sql-index";
public static final transient QName QN = new QName(TAG);
- private SimpleDateFormat[] sdfs;
private String id, tableId, path, format, datatype, column;
private boolean useInCriterias = true;
private String resetOn;
}
public Date getDateValue(final String value) throws ParseException {
+
+ SimpleDateFormat[] sdfs = null;
+
if (StringUtils.isBlank(value)) {
return null;
}
+ if (StringUtils.isBlank(this.format)) {
+ throw new RuntimeException("Undefined format");
+ }
+
+ // a priori, ce test ne sert a rien : voir les appels a getDateValue
if (!"date".equals(this.datatype)) {
return null;
}
- if (this.sdfs == null) {
- if (this.format == null) {
- logger.error("format is null for sql-index " + this.id);
- }
- final StringTokenizer tokenizer = new StringTokenizer(this.format, ";");
- this.sdfs = new SimpleDateFormat[tokenizer.countTokens()];
- for (int count = 0; count < this.sdfs.length; count++) {
- final String s = tokenizer.nextToken();
- this.sdfs[count] = new SimpleDateFormat(s);
- }
+
+ final StringTokenizer tokenizer = new StringTokenizer(this.format, ";");
+ sdfs = new SimpleDateFormat[tokenizer.countTokens()];
+ for (int count = 0; count < sdfs.length; count++) {
+ final String s = tokenizer.nextToken();
+ sdfs[count] = new SimpleDateFormat(s);
}
+
Date ret = null;
int count = 0;
- while (ret == null && count < this.sdfs.length) {
+ while (ret == null && count < sdfs.length) {
try {
- ret = new Date(this.sdfs[count].parse(value).getTime());
+ // la valeur de retour en java.sql.Date, on perd donc les informations horaires de la date.
+ ret = new Date(sdfs[count].parse(value).getTime());
} catch (final Exception pEx) {
count++;
}
if (ret == null) {
throw new ParseException(value + " does not match any of following date patterns : " + this.format + " - " + this.tableId + "." + this.column, 0);
}
+
return ret;
}