diff geo-backend/src/main/java/de/intevation/gnv/geobackend/util/DateUtils.java @ 884:12f88239fb33

Updated Javadocs to the Listed Classes. Also done some Codecleanup and removed unused Methods from the Code. geo-backend/trunk@842 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Fri, 26 Mar 2010 15:23:03 +0000
parents 25be806da62f
children 8b442223741c
line wrap: on
line diff
--- a/geo-backend/src/main/java/de/intevation/gnv/geobackend/util/DateUtils.java	Fri Mar 26 11:07:01 2010 +0000
+++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/util/DateUtils.java	Fri Mar 26 15:23:03 2010 +0000
@@ -15,23 +15,16 @@
  */
 package de.intevation.gnv.geobackend.util;
 
-import org.apache.log4j.Logger;
-
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
+import org.apache.log4j.Logger;
+
 
 /**
- * The class <code>DateUtisl</code> fulfills the following purposes:
- * <ol>
- * <li></li>
- * </ol>
- *
+ * The class <code>DateUtils</code> fulfills the following purposes:
  * @author blume
- * @version 1.0
- * @serial 1.0
- * @see
- * @since 21.12.2007 10:34:01
+ * @author Tim Englich <tim.englich@intevation.de>
  */
 public class DateUtils {
 
@@ -39,90 +32,61 @@
      * Default Logging instance
      */
     private static Logger sLogger = Logger.getLogger(DateUtils.class);
-    private static boolean sDebug = sLogger.isDebugEnabled();
-
-    public static final String DATE_PATTERN = "yyyy.MM.dd HH:mm:ss";
-    public static final String DATE_PATTERN1 = "dd-MMM-yyyy HH:mm:ss";
-    public static final String TimeRangeFilterPattern = "yyyy-MM-dd'T'HH:mm:ssZ";
-    public static final String TimeRangeFilterFormPattern = "dd.MM.yyyy HH:mm";
 
-    public static String getPatternedDateSDF(Date pDate) {
-        SimpleDateFormat fmt = new SimpleDateFormat();
-        fmt.applyPattern(DATE_PATTERN);
-        return fmt.format(pDate);
-    }
-    
+    /**
+     * The Dateformat which will be used e.g for Querying the Database 
+     */
+    public static final String DATE_PATTERN = "yyyy.MM.dd HH:mm:ss";
+
+    private static final String DATE_PATTERN1 = "dd-MMM-yyyy HH:mm:ss";
+
+    /**
+     * The Method returns a Date using the given pattern as a String
+     * @param pDate The Date which should be formatted
+     * @param sPattern The Pattern which should be used.
+     * @return the Date formatted a a String
+     */
     public static String getPatternedDate(Date pDate, String  sPattern) {
-//    	DateTimeZone.setDefault(DateTimeZone.UTC);
-//    	DateTime dtf = new DateTime (pDate);
-//    	String sStr = dtf.toString(sPattern);
-//      return sStr;
-    	 SimpleDateFormat fmt = new SimpleDateFormat();
+         SimpleDateFormat fmt = new SimpleDateFormat();
          fmt.applyPattern(sPattern);
          return fmt.format(pDate);
     }
-    
+
+    /**
+     * Returns the Date as a String formated using the 
+     * @see DateUtils.DATE_PATTERN
+     * @param pDate the Date which should be formatted
+     * @return the given Data as a String
+     */
     public static String getPatternedDateAmer(Date pDate) {
-    	
-    	String sStr = getPatternedDate(pDate, DATE_PATTERN);
-        return sStr;
-    }
-    
-    public static String getPatternedDateGerm(Date pDate) {
-    	
-    	String sStr = getPatternedDate(pDate, DATE_PATTERN1);
-        return sStr;
-    }
-    
-    public static String getPatternedDateTimeRangeFilter(Date pDate) {
-    	
-    	String sStr = getPatternedDate(pDate, TimeRangeFilterPattern);
-        return sStr;
-    }
-    
-    public static String getPatternedDateTimeRangeFilterForm(Date pDate) {
-    	
-    	String sStr = getPatternedDate(pDate, TimeRangeFilterFormPattern);
+        String sStr = getPatternedDate(pDate, DATE_PATTERN);
         return sStr;
     }
-    
-    public synchronized static Date getDateFromStringSDF (String sStr)throws Exception {
-    	SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
-		Date   date = (Date)formatter.parse(sStr);
-		return date;
-    }
-    
-    public  static Date getDateFromString (String sStr)throws Exception {
-    	
-		Date   date = getDateFromString (sStr, DATE_PATTERN1);
-	    return date;
+
+    /**
+     * Thismethod decodes a Datevalue from the given String useing the
+     * @see DateUtils.DATE_PATTERN1 format-
+     * @param sStr The String which contains the encoded Datevalue
+     * @return the decoded Datevalue as an Date-object.
+     * @throws Exception throws all Expetion which occurs during the Process.
+     */
+    public static Date getDateFromString (String sStr)throws Exception {
+        Date   date = getDateFromString (sStr, DATE_PATTERN1);
+        return date;
     }
-    
-    public  static Date getDateFromStringTimeRangeFilter (String sStr)throws Exception {
-    	
-		Date   date = getDateFromString (sStr, TimeRangeFilterPattern);
-	        	return date;
-    } 
-    
-    public  static Date getDateFromStringTimeRangeFilterForm (String sStr)throws Exception {
-    	
-		Date   date = getDateFromString (sStr, TimeRangeFilterFormPattern);
-    	return date;
-    } 
-    
-    public  static Date getDateFromString (String sStr, String sPattern)throws Exception {
-//    	DateTime dtf = null;
-//    	DateTimeZone.setDefault(DateTimeZone.UTC); 
-//    	
-//	    dtf = DateTimeFormat.forPattern(sPattern).parseDateTime(sStr);
-//    	
-//		Date   date = dtf.toDate();
-//    	
-//    	return date;
-    	SimpleDateFormat fmt = new SimpleDateFormat();
+
+    /**
+     * Formats a given Date encoded as a String using the given Pattern
+     * into a Date Object.
+     * @param sStr The String with the encoded DateValue
+     * @param sPattern The pattern which should be used to decode the Date
+     * @return the given Datevalue as an Date-Object.
+     * @throws Exception throws all Expetion which occurs during the Process.
+     */
+    public static Date getDateFromString (String sStr, 
+                                          String sPattern)throws Exception {
+        SimpleDateFormat fmt = new SimpleDateFormat();
         fmt.applyPattern(sPattern);
         return fmt.parse(sStr);
-    } 
-    
-     
+    }
 }

http://dive4elements.wald.intevation.org