Mercurial > dive4elements > gnv-client
view geo-backend/src/main/java/de/intevation/gnv/geobackend/util/DateUtils.java @ 888:65dd801fbee6
Added package description with text 'DOCUMENT ME!'.
geo-backend/trunk@862 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 29 Mar 2010 10:37:04 +0000 |
parents | b757def3ff55 |
children | e5e30090c37c |
line wrap: on
line source
/** * 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 * @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; } /** * 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; } /** * 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); } }