Java Timestamp Create getTimestampXDaysFromY(long startTimeInMillis, int daysFromStartDate)

Here you can find the source of getTimestampXDaysFromY(long startTimeInMillis, int daysFromStartDate)

Description

get Timestamp X Days From Y

License

Open Source License

Declaration

public static Timestamp getTimestampXDaysFromY(long startTimeInMillis, int daysFromStartDate) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.Timestamp;
import java.util.Calendar;

public class Main {
    public static Timestamp getTimestampXDaysFromY(long startTimeInMillis, int daysFromStartDate) {
        Calendar cal = getCalendarXDaysFromY(startTimeInMillis, daysFromStartDate);
        return new Timestamp(cal.getTimeInMillis());
    }//www .  j a  va2  s.  com

    private static Calendar getCalendarXDaysFromY(long startTimeInMillis, int daysFromStartDate) {
        Calendar cal = Calendar.getInstance();
        cal.setTimeInMillis(startTimeInMillis);
        cal.add(Calendar.DAY_OF_YEAR, daysFromStartDate);

        return cal;
    }
}

Related

  1. getTimestampOrNull(Object dbResult)
  2. getTimeStampString()
  3. getTimestampString(long timeInMillis)
  4. getTimeStampStringFormat(Timestamp ts, String fmt)
  5. getTimestampToOracle()
  6. getTimeStrByTimestamp(long timestamp, String tz)
  7. timestamp()
  8. timeStamp()
  9. timestamp2string()