convert string into java.util.date format in java

孤街浪徒 提交于 2019-12-01 17:54:37
maksimov

Try this:

SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");

For future reference read up on the SimpleDateFormat class: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

Use this format -'EEE MMM dd HH:mm:ss z yyyy'

Date date = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy")
                      .parse("Thu Oct 07 11:31:50 IST 2010");
System.out.println(date);

Can't you do like below

   String str = "Thu Oct 07 11:31:50 IST 2010";
   SimpleDateFormat sdf = new SimpleDateFormat("E MMM dd hh:mm:ss   'IST' yyyy");
   SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");
   System.out.println(sdf2.format(sdf.parse(str)));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!