【发布时间】:2011-09-24 12:58:20
【问题描述】:
我有一个字符串
String startDate = "06/27/2007";
现在我必须得到 Date 对象。我的 DateObject 应该与 startDate 的值相同。
我就是这样的
DateFormat df = new SimpleDateFormat("mm/dd/yyyy");
Date startDate = df.parse(startDate);
但是输出是格式的
2007 年 1 月 27 日 00:06:00 PST。
【问题讨论】:
-
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");日期 startDate = null;尝试 { startDate = dateFormat.parse("03/04/1975");字符串 foramtedDate =dateFormat.format(startDate); System.out.println("格式化后的日期为="+foramtedDate); // } catch (ParseException e) { // TODO 自动/生成的 catch 块 e.printStackTrace(); }