public static String parseDate(String inDate, String fmFormat, String toFormat){ SimpleDateFormat fmFormatter = new SimpleDateFormat(fmFormat); SimpleDateFormat toFormatter = new SimpleDateFormat(toFormat); if ( inDate == null ) return ""; // To avoid java.lang.NullPointerException if ( inDate.length() == 0 ) return ""; // Taking care of empty string. Date fromDate = null; try { fromDate = (Date) fmFormatter.parse(inDate); } catch (ParseException e) { e.printStackTrace(); } return toFormatter.format(fromDate); }
Thursday, February 24, 2011
Java Date Format
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment