1 44 package org.jpublish.util; 45 46 import java.text.ParseException ; 47 import java.text.SimpleDateFormat ; 48 import java.util.Date ; 49 50 57 public class DateUtilities { 58 59 private final static DateUtilities dateUtilities = new DateUtilities(); 60 61 66 public static DateUtilities getInstance() { 67 return dateUtilities; 68 } 69 70 78 79 public String format(Date date, String format) { 80 if (date == null) { 81 return ""; 82 } 83 SimpleDateFormat fmt = new SimpleDateFormat (format); 84 return fmt.format(date); 85 } 86 87 96 97 public Date parse(String date, String format) throws ParseException { 98 SimpleDateFormat fmt = new SimpleDateFormat (format); 99 return fmt.parse(date); 100 } 101 102 } 103 104 | Popular Tags |