annotate geo-backend/src/main/java/de/intevation/gnv/geobackend/util/DateUtils.java @ 889:e5e30090c37c

Modified some JavaDoc so that the Warnings that where caused by mistakes are removed. geo-backend/trunk@915 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Tue, 13 Apr 2010 09:30:10 +0000
parents b757def3ff55
children e9ca6be4dbd2
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 /**
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
24 * 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
25 * @author blume
887
b757def3ff55 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 886
diff changeset
26 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27 */
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 public class DateUtils {
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29
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 * Default Logging instance
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 */
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 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
34
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
35 /**
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
36 * 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
37 */
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
38 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
39
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
40 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
41
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 * 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
44 * @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
45 * @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
46 * @return the Date formatted a a String
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
47 */
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 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
49 SimpleDateFormat fmt = new SimpleDateFormat();
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 fmt.applyPattern(sPattern);
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 return fmt.format(pDate);
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 }
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
53
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 * Returns the Date as a String formated using the
889
e5e30090c37c Modified some JavaDoc so that the Warnings that where caused by mistakes are removed.
Tim Englich <tim.englich@intevation.de>
parents: 887
diff changeset
56 * @see de.intevation.gnv.geobackend.util.DateUtils.DATE_PATTERN
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
57 * @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
58 * @return the given Data as a String
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
59 */
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60 public static String getPatternedDateAmer(Date pDate) {
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
61 String sStr = getPatternedDate(pDate, DATE_PATTERN);
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 return sStr;
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 }
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
64
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 * Thismethod decodes a Datevalue from the given String useing the
889
e5e30090c37c Modified some JavaDoc so that the Warnings that where caused by mistakes are removed.
Tim Englich <tim.englich@intevation.de>
parents: 887
diff changeset
67 * @see de.intevation.gnv.geobackend.util.DateUtils.DateUtils.DATE_PATTERN1 format-
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
68 * @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
69 * @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
70 * @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
71 */
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
72 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
73 Date date = getDateFromString (sStr, DATE_PATTERN1);
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
74 return date;
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 }
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
76
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 * 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
79 * into a Date Object.
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
80 * @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
81 * @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
82 * @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
83 * @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
84 */
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
85 public static Date getDateFromString (String sStr,
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
86 String sPattern)throws Exception {
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
87 SimpleDateFormat fmt = new SimpleDateFormat();
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
88 fmt.applyPattern(sPattern);
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
89 return fmt.parse(sStr);
884
12f88239fb33 Updated Javadocs to the Listed Classes.
Tim Englich <tim.englich@intevation.de>
parents: 142
diff changeset
90 }
129
110e3ac1b7d2 Library Dependencies Added to pom.xml-File
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
91 }

http://dive4elements.wald.intevation.org