Mercurial > dive4elements > gnv-client
view geo-backend/src/main/java/de/intevation/gnv/geobackend/util/DateUtils.java @ 1120:d387a97807a3
Added an INFO log statement displaying the execution time of a database query.
geo-backend/trunk@1137 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 31 May 2010 07:23:21 +0000 |
parents | 02cd2935b5fa |
children |
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 * <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); } }