Java examples for java.util:Date Format
The following code shows how to Datemill Format.
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main{ public static void main(String[] argv){ String date = "2018-02-21 12:12:12"; DatemillFormat(date);//from www . j a va 2s. c o m } public static void DatemillFormat(String date) throws ParseException { SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss"); Date timestr = format.parse(date); long time = timestr.getTime() / 1000; System.out.println(date + ":" + time); } }