Here you can find the source of addTimes(String dateTime, int second)
public static String addTimes(String dateTime, int second)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; public class Main { public static String addTimes(String dateTime, int second) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); java.util.Date date1 = null; try {/* w ww . jav a 2 s .c om*/ date1 = format.parse(dateTime); } catch (ParseException e) { e.printStackTrace(); } long Time = (date1.getTime() / 1000) + second; date1.setTime(Time * 1000); String mydate1 = format.format(date1); return mydate1; } public static long getTime(String time) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { return format.parse("1970-01-01 " + time).getTime() - format.parse("1970-01-01 00:00:00").getTime(); } catch (ParseException e) { e.printStackTrace(); } return 0; } }