lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject svn commit: r907562 - in /lucene/solr/trunk/contrib/dataimporthandler: CHANGES.txt src/main/java/org/apache/solr/handler/dataimport/DateFormatTransformer.java
Date Mon, 08 Feb 2010 06:57:55 GMT
Author: noble
Date: Mon Feb  8 06:57:53 2010
New Revision: 907562

URL: http://svn.apache.org/viewvc?rev=907562&view=rev
Log:
SOLR-1762: DateFormatTransformer does not work correctly with non-default locale dates

Modified:
    lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt
    lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DateFormatTransformer.java

Modified: lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt?rev=907562&r1=907561&r2=907562&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt (original)
+++ lucene/solr/trunk/contrib/dataimporthandler/CHANGES.txt Mon Feb  8 06:57:53 2010
@@ -55,6 +55,8 @@
 
 * SOLR-1759: $skipDoc was not working correctly (Gian Marco Tagliani via noble)
 
+* SOLR-1762: DateFormatTransformer does not work correctly with non-default locale dates
(tommy chheng via noble)
+
 Other Changes
 ----------------------
 

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DateFormatTransformer.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DateFormatTransformer.java?rev=907562&r1=907561&r2=907562&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DateFormatTransformer.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DateFormatTransformer.java
Mon Feb  8 06:57:53 2010
@@ -47,7 +47,14 @@
 
   @SuppressWarnings("unchecked")
   public Object transformRow(Map<String, Object> aRow, Context context) {
+
     for (Map<String, String> map : context.getAllEntityFields()) {
+      Locale locale = Locale.getDefault();
+      String customLocale = map.get("locale");
+      if(customLocale != null){
+        locale = new Locale(customLocale);
+      }
+
       String fmt = map.get(DATE_TIME_FMT);
       if (fmt == null)
         continue;
@@ -61,12 +68,12 @@
           List inputs = (List) o;
           List<Date> results = new ArrayList<Date>();
           for (Object input : inputs) {
-            results.add(process(input, fmt));
+            results.add(process(input, fmt, locale));
           }
           aRow.put(column, results);
         } else {
           if (o != null) {
-            aRow.put(column, process(o, fmt));
+            aRow.put(column, process(o, fmt, locale));
           }
         }
       } catch (ParseException e) {
@@ -76,14 +83,14 @@
     return aRow;
   }
 
-  private Date process(Object value, String format) throws ParseException {
+  private Date process(Object value, String format, Locale locale) throws ParseException
{
     if (value == null) return null;
     String strVal = value.toString().trim();
     if (strVal.length() == 0)
       return null;
     SimpleDateFormat fmt = fmtCache.get(format);
     if (fmt == null) {
-      fmt = new SimpleDateFormat(format);
+      fmt = new SimpleDateFormat(format, locale);
       fmtCache.put(format, fmt);
     }
     return fmt.parse(strVal);



Mime
View raw message