Skip to content

Commit

Permalink
Fix for feliperazeek#34 (cannot parse indexed date on record retrieval)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgooren committed Dec 5, 2011
1 parent f53e89e commit 5739d04
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/play/modules/elasticsearch/util/ReflectionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import org.elasticsearch.common.xcontent.XContentBuilder;

import play.Logger;

/**
Expand All @@ -45,9 +47,6 @@ public abstract class ReflectionUtil {
/** The Constant classFieldsCache. */
private static final ConcurrentMap<String, List<Field>> classFieldsCache = new ConcurrentHashMap<String, List<Field>>();

/** The Constant DATE_FORMAT. */
public static final String DATE_FORMAT = "MM/dd/yyyy HH:mm:ss.SSS";

/**
* Instantiates a new reflection util.
*/
Expand Down Expand Up @@ -522,8 +521,8 @@ private static Date convertToDate(Object value) {
*/
private static Date getDate(String val) {
try {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
return sdf.parse(val);
// Use ES internal converter
return XContentBuilder.defaultDatePrinter.parseDateTime(val).toDate();
} catch (Throwable t) {
Logger.error(ExceptionUtil.getStackTrace(t), val);
}
Expand Down

0 comments on commit 5739d04

Please sign in to comment.