Mercurial > dive4elements > gnv-client
diff geo-backend/src/main/java/de/intevation/gnv/geobackend/util/DateUtils.java @ 894:d674cef2ca0d
Using unix line endings only.
geo-backend/trunk@939 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 18 Apr 2010 09:22:38 +0000 |
parents | e9ca6be4dbd2 |
children | 02cd2935b5fa |
line wrap: on
line diff
--- a/geo-backend/src/main/java/de/intevation/gnv/geobackend/util/DateUtils.java Sat Apr 17 09:28:02 2010 +0000 +++ b/geo-backend/src/main/java/de/intevation/gnv/geobackend/util/DateUtils.java Sun Apr 18 09:22:38 2010 +0000 @@ -1,91 +1,91 @@ -/** - * 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 $ - * Source: $Source: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/util/DateUtils.java,v $ - * created by: Stefan Blume (blume) - * erstellt am: 21.12.2007 - * Copyright: con terra GmbH, 2005 - * - * modified by: $Author: drewnak $ - * modified on: $Date: 2008/08/18 14:50:33 $ - * Version: $Revision: 1.2 $ - * TAG: $Name: $ - * locked from: $Locker: $ - * CVS State: $State: Exp $ - * Project: $ProjectName$ - */ -package de.intevation.gnv.geobackend.util; - -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.apache.log4j.Logger; - -/** - * The class <code>DateUtils</code> fulfills the following purposes: - * @author blume - * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> - */ -public class DateUtils { - - /** - * Default Logging instance - */ - private static Logger sLogger = Logger.getLogger(DateUtils.class); - - /** - * 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) { - SimpleDateFormat fmt = new SimpleDateFormat(); - fmt.applyPattern(sPattern); - return fmt.format(pDate); - } - - /** - * Returns the Date as a String formated using the - * <code>DateUtils.DATE_PATTERN</code> format- - * @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; - } - - /** - * This method decodes a Datevalue from the given String useing the - * <code>DateUtils.DATE_PATTERN1</code> 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; - } - - /** - * 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); - } -} +/** + * 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 $ + * Source: $Source: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/util/DateUtils.java,v $ + * created by: Stefan Blume (blume) + * erstellt am: 21.12.2007 + * Copyright: con terra GmbH, 2005 + * + * modified by: $Author: drewnak $ + * modified on: $Date: 2008/08/18 14:50:33 $ + * Version: $Revision: 1.2 $ + * TAG: $Name: $ + * locked from: $Locker: $ + * CVS State: $State: Exp $ + * Project: $ProjectName$ + */ +package de.intevation.gnv.geobackend.util; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.apache.log4j.Logger; + +/** + * The class <code>DateUtils</code> fulfills the following purposes: + * @author blume + * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> + */ +public class DateUtils { + + /** + * Default Logging instance + */ + private static Logger sLogger = Logger.getLogger(DateUtils.class); + + /** + * 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) { + SimpleDateFormat fmt = new SimpleDateFormat(); + fmt.applyPattern(sPattern); + return fmt.format(pDate); + } + + /** + * Returns the Date as a String formated using the + * <code>DateUtils.DATE_PATTERN</code> format- + * @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; + } + + /** + * This method decodes a Datevalue from the given String useing the + * <code>DateUtils.DATE_PATTERN1</code> 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; + } + + /** + * 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); + } +}