Java Timestamp Create getTimestampDiff(int n)

Here you can find the source of getTimestampDiff(int n)

Description

get Timestamp Diff

License

Apache License

Declaration

public static Timestamp getTimestampDiff(int n) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static Timestamp getTimestampDiff(int n) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date d = new Date();
        Date dayDiff = new Date(d.getTime() + n * 24 * 3600 * 1000L);
        String time = df.format(dayDiff);
        return Timestamp.valueOf(time);
    }/*w  ww .  j  av  a 2 s.  c  om*/
}

Related

  1. getTimestampBeforeMs(long someMs)
  2. getTimeStampByFormat(String style)
  3. getTimestampDate(long timestamp)
  4. getTimestampDate(Timestamp ts)
  5. getTimestampDateDotTime()
  6. getTimestampedPNGFile(File saveDir)
  7. getTimestampedVideoFileName()
  8. getTimestampFormat()
  9. getTimestampFormat()