package cn.com.waegg.tmp; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class DateTest { public static void main(String[] args) throws ParseException { System.out.println(getDate("2014年11月12日 07时20分")); } /** * * @Description: SimpleDateFormat构造函数里的日期格式要和parse的格式相同 * @param time * @return * @return Date * @throws * @author beyond * @date 2015-7-13 */ static String getDate(String time){ DateFormat nowTime= new SimpleDateFormat("yyyy年MM月dd日 HH时mm分"); Date nowdate = null; try { nowdate = nowTime.parse(time); } catch (ParseException e) { e.printStackTrace(); } String dateStr = DateFormat.getDateInstance(DateFormat.FULL).format(nowdate); return dateStr ; } }
java 字符串转换日期
猜你喜欢
转载自bugyun.iteye.com/blog/2226963
今日推荐
周排行