Date或子类的输出格式(要求类型不能变)

比如Person的成员变量 java.util.Date createTime;

现在想要System.out.println(person.getCreateTime());输出的结果是 2015-12-12 12:12:12 .

但现在输出的是Sun Apr 12 23:56:56 CST 2015 CST格式。

这里明显不能使用SimpleDateFormat、因为需要的是Date的数据(实际情况中使用了反射)。

尝试过子类Timestamp,但是这个家伙是精确到毫秒,输出的是 2015-12-12 12:12:12 .0 。

对于person.getCreateTime()的问题,应该怎么写?必须是日期对象,不是字符串。

自己写一个类,从Date派生,重写toString
你的getCreateTime()返回这个类的对象