Sat Nov 27, 2010 9:49 pm
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
public class DateUtils {
public static String formateDate(Date date, String pattern) {
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
return formatter.format(date);
}
public Date convertToDate(String strDate, String pattern) {
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
Date date = null;
System.out.println("Try to convert= " + strDate + " using= " + pattern);
try {
date = (Date) formatter.parse(strDate);
} catch (ParseException ex) {
Logger.getLogger(DateUtils.class.getName()).log(Level.SEVERE, null, ex);
}
return date;
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.