01: package ru.emdev.EmForge.util;
02:
03: import java.text.ParseException;
04: import java.util.Date;
05:
06: import org.apache.commons.logging.Log;
07: import org.apache.commons.logging.LogFactory;
08:
09: import com.ibm.icu.text.SimpleDateFormat;
10:
11: /**
12: * Helper class with some 'Date' utils functions used in EmForge
13: */
14: public class DateUtils {
15: private static final Log log = LogFactory.getLog(DateUtils.class);
16:
17: private static final SimpleDateFormat htmlDateFormater;
18:
19: private static final String HTML_FRIENDLY_DATE_FORMAT = "MM-dd-yyyy";
20:
21: static {
22: htmlDateFormater = new SimpleDateFormat(
23: HTML_FRIENDLY_DATE_FORMAT);
24: }
25:
26: public static String encodedDate(Date date) {
27: if (date == null) {
28: return "00-00-0000";
29: } else {
30: return htmlDateFormater.format(date);
31: }
32: }
33:
34: public static Date getEncodedDate(String dateString) {
35: Date date = new Date();
36:
37: try {
38: date = htmlDateFormater.parse(dateString);
39: } catch (ParseException e) {
40: log.error("Date Parse Error" + e.toString());
41: }
42: return date;
43: }
44: }
|