public class DateTypeUtil { public static Date changeDateType(Date date){ Date yuanDate = new DateYuan(date); return yuanDate; } static class DateYuan extends Date { private Date date; public DateYuan(Date date) { this.date = date; } @Override public String toString() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String format = sdf.format(date); return format; } } }