<分区>
我正在尝试使用以下代码将字符串解析为日期:
public static Date dateFormatter(String s)
{
SimpleDateFormat ft = new SimpleDateFormat ("MMddYYYY");
Date excelDate=null;
try
{
excelDate = ft.parse(s);
Date formatString = ft.format(excelDate);
System.out.println("Date to be printed in Excel is :" +formatString);
return excelDate;
}
catch(Exception ae)
{
System.out.println("No date");
}
return excelDate;
}
我正在传递参数 "04202017"
。
这个功能对我不起作用。我无法弄清楚我做错了什么。谁能帮帮我?