01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package info.jtrac.util;
18:
19: import java.text.Format;
20: import java.text.SimpleDateFormat;
21: import java.util.Date;
22:
23: /**
24: * Date Formatting helper, currently date formats are hard-coded for the entire app
25: * hence the use of static SimpleDateFormat instances, although they are known not to be synchronized
26: */
27: public class DateUtils {
28:
29: private static Format dateFormat = new SimpleDateFormat(
30: "yyyy-MM-dd");
31: private static Format dateTimeFormat = new SimpleDateFormat(
32: "yyyy-MM-dd HH:mm:ss");
33:
34: public static String format(Date date) {
35: return date == null ? "" : dateFormat.format(date);
36: }
37:
38: public static String formatTimeStamp(Date date) {
39: return date == null ? "" : dateTimeFormat.format(date);
40: }
41:
42: }
|