Mercurial > dive4elements > gnv-client
comparison geo-backend/src/main/java/de/intevation/gnv/geobackend/util/DateUtils.java @ 662:755dd2fa4a0a 0.5
merged geo-backend/0.5
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:13:53 +0200 |
parents | 25be806da62f |
children | 12f88239fb33 |
comparison
equal
deleted
inserted
replaced
657:af3f56758f59 | 662:755dd2fa4a0a |
---|---|
1 /** | |
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 $ | |
3 * Source: $Source: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/util/DateUtils.java,v $ | |
4 * created by: Stefan Blume (blume) | |
5 * erstellt am: 21.12.2007 | |
6 * Copyright: con terra GmbH, 2005 | |
7 * | |
8 * modified by: $Author: drewnak $ | |
9 * modified on: $Date: 2008/08/18 14:50:33 $ | |
10 * Version: $Revision: 1.2 $ | |
11 * TAG: $Name: $ | |
12 * locked from: $Locker: $ | |
13 * CVS State: $State: Exp $ | |
14 * Project: $ProjectName$ | |
15 */ | |
16 package de.intevation.gnv.geobackend.util; | |
17 | |
18 import org.apache.log4j.Logger; | |
19 | |
20 import java.text.SimpleDateFormat; | |
21 import java.util.Date; | |
22 | |
23 | |
24 /** | |
25 * The class <code>DateUtisl</code> fulfills the following purposes: | |
26 * <ol> | |
27 * <li></li> | |
28 * </ol> | |
29 * | |
30 * @author blume | |
31 * @version 1.0 | |
32 * @serial 1.0 | |
33 * @see | |
34 * @since 21.12.2007 10:34:01 | |
35 */ | |
36 public class DateUtils { | |
37 | |
38 /** | |
39 * Default Logging instance | |
40 */ | |
41 private static Logger sLogger = Logger.getLogger(DateUtils.class); | |
42 private static boolean sDebug = sLogger.isDebugEnabled(); | |
43 | |
44 public static final String DATE_PATTERN = "yyyy.MM.dd HH:mm:ss"; | |
45 public static final String DATE_PATTERN1 = "dd-MMM-yyyy HH:mm:ss"; | |
46 public static final String TimeRangeFilterPattern = "yyyy-MM-dd'T'HH:mm:ssZ"; | |
47 public static final String TimeRangeFilterFormPattern = "dd.MM.yyyy HH:mm"; | |
48 | |
49 public static String getPatternedDateSDF(Date pDate) { | |
50 SimpleDateFormat fmt = new SimpleDateFormat(); | |
51 fmt.applyPattern(DATE_PATTERN); | |
52 return fmt.format(pDate); | |
53 } | |
54 | |
55 public static String getPatternedDate(Date pDate, String sPattern) { | |
56 // DateTimeZone.setDefault(DateTimeZone.UTC); | |
57 // DateTime dtf = new DateTime (pDate); | |
58 // String sStr = dtf.toString(sPattern); | |
59 // return sStr; | |
60 SimpleDateFormat fmt = new SimpleDateFormat(); | |
61 fmt.applyPattern(sPattern); | |
62 return fmt.format(pDate); | |
63 } | |
64 | |
65 public static String getPatternedDateAmer(Date pDate) { | |
66 | |
67 String sStr = getPatternedDate(pDate, DATE_PATTERN); | |
68 return sStr; | |
69 } | |
70 | |
71 public static String getPatternedDateGerm(Date pDate) { | |
72 | |
73 String sStr = getPatternedDate(pDate, DATE_PATTERN1); | |
74 return sStr; | |
75 } | |
76 | |
77 public static String getPatternedDateTimeRangeFilter(Date pDate) { | |
78 | |
79 String sStr = getPatternedDate(pDate, TimeRangeFilterPattern); | |
80 return sStr; | |
81 } | |
82 | |
83 public static String getPatternedDateTimeRangeFilterForm(Date pDate) { | |
84 | |
85 String sStr = getPatternedDate(pDate, TimeRangeFilterFormPattern); | |
86 return sStr; | |
87 } | |
88 | |
89 public synchronized static Date getDateFromStringSDF (String sStr)throws Exception { | |
90 SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); | |
91 Date date = (Date)formatter.parse(sStr); | |
92 return date; | |
93 } | |
94 | |
95 public static Date getDateFromString (String sStr)throws Exception { | |
96 | |
97 Date date = getDateFromString (sStr, DATE_PATTERN1); | |
98 return date; | |
99 } | |
100 | |
101 public static Date getDateFromStringTimeRangeFilter (String sStr)throws Exception { | |
102 | |
103 Date date = getDateFromString (sStr, TimeRangeFilterPattern); | |
104 return date; | |
105 } | |
106 | |
107 public static Date getDateFromStringTimeRangeFilterForm (String sStr)throws Exception { | |
108 | |
109 Date date = getDateFromString (sStr, TimeRangeFilterFormPattern); | |
110 return date; | |
111 } | |
112 | |
113 public static Date getDateFromString (String sStr, String sPattern)throws Exception { | |
114 // DateTime dtf = null; | |
115 // DateTimeZone.setDefault(DateTimeZone.UTC); | |
116 // | |
117 // dtf = DateTimeFormat.forPattern(sPattern).parseDateTime(sStr); | |
118 // | |
119 // Date date = dtf.toDate(); | |
120 // | |
121 // return date; | |
122 SimpleDateFormat fmt = new SimpleDateFormat(); | |
123 fmt.applyPattern(sPattern); | |
124 return fmt.parse(sStr); | |
125 } | |
126 | |
127 | |
128 } |