- public static Date date(String date_str) {
- try {
- Calendar zcal = Calendar.getInstance();// 日期类
- Timestamp timestampnow = new Timestamp(zcal.getTimeInMillis());// 转换成正常的日期格式
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");// 改为需要的东西
- ParsePosition pos = new ParsePosition(0);
- java.util.Date current = formatter.parse(date_str, pos);
- timestampnow = new Timestamp(current.getTime());
- return timestampnow;
- }
- catch (NullPointerException e) {
- return null;
- }
- }
来源: http://www.bubuko.com/infodetail-2649631.html