Here you can find the source of addTime(Date date, int mode, int amount)
protected static Date addTime(Date date, int mode, int amount)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { protected static Date addTime(Date date, int mode, int amount) { Calendar cal = Calendar.getInstance(); if (date != null) cal.setTime(date);/*from ww w .j ava 2 s . c o m*/ cal.add(mode, amount); return cal.getTime(); } private static Calendar setTime(final Calendar calendat, final String[] test) { if (test.length == 3) { calendat.set(Calendar.HOUR_OF_DAY, Integer.parseInt(test[0].trim())); calendat.set(Calendar.MINUTE, Integer.parseInt(test[1].trim())); calendat.set(Calendar.SECOND, Integer.parseInt(test[2].trim())); } if (test.length == 2) { calendat.set(Calendar.HOUR_OF_DAY, Integer.parseInt(test[0].trim())); calendat.set(Calendar.MINUTE, Integer.parseInt(test[1].trim())); calendat.set(Calendar.SECOND, 0); } return calendat; } }