Java tutorial
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getTime(String user_time) { String re_time = null; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date d; try { d = sdf.parse(user_time); long l = d.getTime(); String str = String.valueOf(l); re_time = str.substring(0, 10); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return re_time; } }