12/9/14:(月日前没0) SimpleDateFormat("M/d/yy")
12/09/14:(月日前有0) SimpleDateFormat("MM/dd/yy")
- Timestamp ts = new Timestamp(System.currentTimeMillis());
- String tsStr = "";
- DateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
- try {
- //方法一
- tsStr = sdf.format(ts);
- System.out.println(tsStr);
- //方法二
- tsStr = ts.toString();
- System.out.println(tsStr);
- } catch (Exception e) {
- e.printStackTrace();
- }
时间: 2024-11-04 19:35:23