how to convert java string to Date object

I have a string String startDate = "06/27/2007"; now i have to get Date object. My DateObject should be the same value as of startDate. I am doing like this DateFormat df = new SimpleDateFormat("mm/dd/yyyy"); Date startDate = df.parse(startDate); But the output is in format >Jan 27 00:06:00 PST 2007.
DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); Date startDate = null; try { startDate = dateFormat.parse("03/04/1975"); String foramtedDate =dateFormat.format(startDate); System.out.println("After format Date is="+foramtedDate); // } catch (ParseException e) { // TODO Auto/generated catch block e.printStackTrace(); }

以上就是how to convert java string to Date object的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏