Here you can find the source of getIncrementDaysSecond(String strDate, int sec)
public static Date getIncrementDaysSecond(String strDate, int sec) throws Exception
//package com.java2s; /*//from www. j a v a 2s.c o m * @(#)DateUtil.java 1.0 2004/03/15 * * Copyright 2001 - 2004 Bestech, Inc. All rights reserved. * This software is the proprietary information of Bestech, Inc. * Use is subject to license terms. */ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static Date getIncrementDaysSecond(String strDate, int sec) throws Exception { SimpleDateFormat sdf = null; Calendar calendar = new GregorianCalendar(); Date date = null; int year = 0; int month = 0; int day = 0; int hour = 0; int minute = 0; int second = 0; if (strDate.length() == 10) { sdf = new SimpleDateFormat("yyyyMMdd", java.util.Locale.KOREA); } else { sdf = new SimpleDateFormat("yyyyMMddHHmmss", java.util.Locale.KOREA); } try { Date tmpDate = sdf.parse(strDate); } catch (Exception e) { throw new Exception(e.getMessage()); } try { year = Integer.parseInt(strDate.substring(0, 4)); month = Integer.parseInt(strDate.substring(4, 6)); day = Integer.parseInt(strDate.substring(6, 8)); hour = Integer.parseInt(strDate.substring(8, 10)); minute = Integer.parseInt(strDate.substring(10, 12)); second = Integer.parseInt(strDate.substring(12, 14)); } catch (Exception e) { hour = 0; minute = 0; second = 0; // throw new Exception(e.getMessage()+"Here"); } calendar.set(year, month - 1, day, hour, minute, second + sec); try { date = calendar.getTime(); } catch (Exception e) { } return date; } }