annotate 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
rev   line source
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 * Title: DateUtisl, $Header: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/util/DateUtils.java,v 1.2 2008/08/18 14:50:33 drewnak Exp $
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 * Source: $Source: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/util/DateUtils.java,v $
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 * created by: Stefan Blume (blume)
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5 * erstellt am: 21.12.2007
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 * Copyright: con terra GmbH, 2005
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 *
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 * modified by: $Author: drewnak $
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 * modified on: $Date: 2008/08/18 14:50:33 $
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10 * Version: $Revision: 1.2 $
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 * TAG: $Name: $
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12 * locked from: $Locker: $
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 * CVS State: $State: Exp $
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 * Project: $ProjectName$
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 */
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 package de.intevation.gnv.geobackend.util;
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import java.text.SimpleDateFormat;
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import java.util.Date;
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
21 import org.apache.log4j.Logger;
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
22
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 /**
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
25 * The class <code>DateUtils</code> fulfills the following purposes:
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26 * @author blume
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
27 * @author Tim Englich <tim.englich@intevation.de>
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 */
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 public class DateUtils {
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 /**
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 * Default Logging instance
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 */
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 private static Logger sLogger = Logger.getLogger(DateUtils.class);
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
36 /**
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
37 * The Dateformat which will be used e.g for Querying the Database
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
38 */
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
39 public static final String DATE_PATTERN = "yyyy.MM.dd HH:mm:ss";
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
40
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
41 private static final String DATE_PATTERN1 = "dd-MMM-yyyy HH:mm:ss";
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
42
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
43 /**
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
44 * The Method returns a Date using the given pattern as a String
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
45 * @param pDate The Date which should be formatted
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
46 * @param sPattern The Pattern which should be used.
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
47 * @return the Date formatted a a String
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
48 */
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 public static String getPatternedDate(Date pDate, String sPattern) {
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
50 SimpleDateFormat fmt = new SimpleDateFormat();
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 fmt.applyPattern(sPattern);
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 return fmt.format(pDate);
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53 }
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
54
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
55 /**
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
56 * Returns the Date as a String formated using the
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
57 * @see DateUtils.DATE_PATTERN
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
58 * @param pDate the Date which should be formatted
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
59 * @return the given Data as a String
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
60 */
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 public static String getPatternedDateAmer(Date pDate) {
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
62 String sStr = getPatternedDate(pDate, DATE_PATTERN);
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 return sStr;
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 }
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
65
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
66 /**
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
67 * Thismethod decodes a Datevalue from the given String useing the
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
68 * @see DateUtils.DATE_PATTERN1 format-
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
69 * @param sStr The String which contains the encoded Datevalue
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
70 * @return the decoded Datevalue as an Date-object.
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
71 * @throws Exception throws all Expetion which occurs during the Process.
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
72 */
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
73 public static Date getDateFromString (String sStr)throws Exception {
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
74 Date date = getDateFromString (sStr, DATE_PATTERN1);
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
75 return date;
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76 }
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
77
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
78 /**
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
79 * Formats a given Date encoded as a String using the given Pattern
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
80 * into a Date Object.
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
81 * @param sStr The String with the encoded DateValue
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
82 * @param sPattern The pattern which should be used to decode the Date
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
83 * @return the given Datevalue as an Date-Object.
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
84 * @throws Exception throws all Expetion which occurs during the Process.
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
85 */
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
86 public static Date getDateFromString (String sStr,
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
87 String sPattern)throws Exception {
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
88 SimpleDateFormat fmt = new SimpleDateFormat();
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
89 fmt.applyPattern(sPattern);
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
90 return fmt.parse(sStr);
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
91 }
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
92 }

http://dive4elements.wald.intevation.org