1 public static Date date(String date_str) { 2 try { 3 Calendar zcal = Calendar.getInstance();//日期类 4 Timestamp timestampnow = new Timestamp(zcal.getTimeInMillis());//转换成正常的日期格式 5 SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");//改为需要的东西 6 ParsePosition pos = new ParsePosition(0); 7 java.util.Date current = formatter.parse(date_str, pos); 8 timestampnow = new Timestamp(current.getTime()); 9 return timestampnow; 10 } 11 catch (NullPointerException e) { 12 return null; 13 } 14 }
java中字符串转换Date类型
猜你喜欢
转载自www.cnblogs.com/weibanggang/p/9195840.html
今日推荐
周排行