01: package org.zkforge.timeline.util;
02:
03: import java.text.SimpleDateFormat;
04: import java.util.Date;
05: import java.util.Locale;
06:
07: public class TimelineUtil {
08: private final static SimpleDateFormat sdf = new SimpleDateFormat(
09: "EEE, dd MMM yyyy HH:mm:ss ", Locale.US);
10:
11: private final static SimpleDateFormat sdf2 = new SimpleDateFormat(
12: "Z", Locale.US);
13:
14: public static String formatDateTime(Date date) {
15: String temp = sdf.format(date);
16: String offset = sdf2.format(date);
17: StringBuffer ret = new StringBuffer();
18: ret.append(temp);
19: ret.append("GMT");
20: ret.append(offset);
21: //System.out.println(ret);
22: return ret.toString();
23: }
24:
25: public static String convertIntervalUnitFromName(String unitName) {
26: String ret = null;
27: unitName = unitName.toUpperCase();
28: if ("MILLISECOND".equals(unitName))
29: ret = "0";
30: else if ("SECOND".equals(unitName))
31: ret = "1";
32: else if ("MINUTE".equals(unitName))
33: ret = "2";
34: else if ("HOUR".equals(unitName))
35: ret = "3";
36: else if ("DAY".equals(unitName))
37: ret = "4";
38: else if ("WEEK".equals(unitName))
39: ret = "5";
40: else if ("MONTH".equals(unitName))
41: ret = "6";
42: else if ("YEAR".equals(unitName))
43: ret = "7";
44: else if ("DECADE".equals(unitName))
45: ret = "8";
46: else if ("CENTURY".equals(unitName))
47: ret = "9";
48: else if ("MILLENNIUM".equals(unitName))
49: ret = "10";
50: else if ("EPOCH".equals(unitName))
51: ret = "-1";
52: else if ("ERA".equals(unitName))
53: ret = "-2";
54: return ret;
55: }
56: }
|