[Schmitzm-commits] r1609 - in trunk/schmitzm-core/src/main: java/de/schmitzm/lang resources/de/schmitzm/data/resource/locales
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Jun 14 16:39:30 CEST 2011
Author: mojays
Date: 2011-06-14 16:39:29 +0200 (Tue, 14 Jun 2011)
New Revision: 1609
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
trunk/schmitzm-core/src/main/resources/de/schmitzm/data/resource/locales/DataResourceBundle_fr.properties
Log:
LangUtil.parseDate(..)
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java 2011-06-14 11:08:12 UTC (rev 1608)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java 2011-06-14 14:39:29 UTC (rev 1609)
@@ -37,6 +37,7 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.text.DateFormat;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
@@ -229,6 +230,36 @@
return combinedDateCal.getTime();
}
+ /**
+ * Tries several date formats to parse a date string.
+ * @param dateStr the date string to parse
+ * @param pattern date format pattern to try
+ */
+ public static Date parseDate(String dateStr, String... pattern) throws ParseException {
+ DateFormat[] formats = new DateFormat[pattern.length];
+ for (int i=0; i<formats.length; i++)
+ formats[i] = new SimpleDateFormat(pattern[i]);
+ return parseDate(dateStr, formats);
+ }
+
+ /**
+ * Tries several date formats to parse a date string.
+ * @param dateStr the date string to parse
+ * @param formats date formats to try
+ */
+ public static Date parseDate(String dateStr, DateFormat... formats) throws ParseException {
+ if (dateStr == null || dateStr.trim().equals(""))
+ return null;
+ dateStr = dateStr.trim();
+ for (DateFormat format : formats)
+ try {
+ Date date = format.parse(dateStr);
+ return date;
+ } catch (Exception err) {
+ }
+ throw new ParseException("Could not parse date: "+dateStr,0);
+ }
+
/**
* Returns an exception stack as string.
*/
Modified: trunk/schmitzm-core/src/main/resources/de/schmitzm/data/resource/locales/DataResourceBundle_fr.properties
===================================================================
--- trunk/schmitzm-core/src/main/resources/de/schmitzm/data/resource/locales/DataResourceBundle_fr.properties 2011-06-14 11:08:12 UTC (rev 1608)
+++ trunk/schmitzm-core/src/main/resources/de/schmitzm/data/resource/locales/DataResourceBundle_fr.properties 2011-06-14 14:39:29 UTC (rev 1609)
@@ -1,22 +1,22 @@
-DistanceUnit.FEET=Pieds
-DistanceUnit.FEET.Abb=ft
-DistanceUnit.KM=Kilom\u00e8tre
-DistanceUnit.KM.Abb=km
-DistanceUnit.METERS=M\u00e8tre
-DistanceUnit.METERS.Abb=m
-DistanceUnit.MILES=Lieue
-DistanceUnit.MILES.Abb=mi
-DistanceUnit.YARDS=Yards
-DistanceUnit.YARDS.Abb=yt
-RasterDim.CellHeight=Hauteur de la cellule
-RasterDim.CellWidth=Largeur de la cellule
-RasterDim.ErrorMess=${0} de '${1}' n'est pas compatible \u00e0 '${2}'...
-RasterDim.GridHeight=Hauteur de la trame
-RasterDim.GridWidth=Largeur de la trame
-RasterDim.SampleType=Type de donn\u00e9e de la trame
-RasterOperationTree.AllowedIdx=permet: 0 \u00e0 ${0}
-RasterOperationTree.NoneAllowed=aucune autoris\u00e9e
-RasterOperationTree.err.FilterReferenceNotAllowed=Le filtre peut \u00eatre seulement appliqu\u00e9 sur des r\u00e9f\u00e9rences de la trame
-RasterOperationTree.err.InvalidFilterReference=R\u00e9f\u00e9rence de filtre non valide 'F${0}' (${1})
-RasterOperationTree.err.InvalidRasterReference=R\u00e9f\u00e9rence de filtre non valide '#${0}' (${1})
-RasterOperationTree.err.NonNumericResult=Le calculatrice de la trame peut seulement traiter des r\u00e9sultats num\u00e9riques: ${0}
+DistanceUnit.FEET=Pieds
+DistanceUnit.FEET.Abb=ft
+DistanceUnit.KM=Kilom\u00e8tre
+DistanceUnit.KM.Abb=km
+DistanceUnit.METERS=M\u00e8tre
+DistanceUnit.METERS.Abb=m
+DistanceUnit.MILES=Lieue
+DistanceUnit.MILES.Abb=mi
+DistanceUnit.YARDS=Yards
+DistanceUnit.YARDS.Abb=yt
+RasterDim.CellHeight=Hauteur de la cellule
+RasterDim.CellWidth=Largeur de la cellule
+RasterDim.ErrorMess=${0} de '${1}' n'est pas compatible \u00e0 '${2}'...
+RasterDim.GridHeight=Hauteur de la trame
+RasterDim.GridWidth=Largeur de la trame
+RasterDim.SampleType=Type de donn\u00e9e de la trame
+RasterOperationTree.AllowedIdx=permet: 0 \u00e0 ${0}
+RasterOperationTree.NoneAllowed=aucune autoris\u00e9e
+RasterOperationTree.err.FilterReferenceNotAllowed=Le filtre peut \u00eatre seulement appliqu\u00e9 sur des r\u00e9f\u00e9rences de la trame
+RasterOperationTree.err.InvalidFilterReference=R\u00e9f\u00e9rence de filtre non valide 'F${0}' (${1})
+RasterOperationTree.err.InvalidRasterReference=R\u00e9f\u00e9rence de filtre non valide '#${0}' (${1})
+RasterOperationTree.err.NonNumericResult=Le calculatrice de la trame peut seulement traiter des r\u00e9sultats num\u00e9riques: ${0}
More information about the Schmitzm-commits
mailing list