Java Timestamp minusHours(Timestamp ts, int hours)

Here you can find the source of minusHours(Timestamp ts, int hours)

Description

minus Hours

License

Open Source License

Declaration

public static Timestamp minusHours(Timestamp ts, int hours) 

Method Source Code


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

import java.sql.Timestamp;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

public class Main {
    public static Timestamp minusHours(Timestamp ts, int hours) {
        DateTime dateTime = new DateTime(ts.getTime(), DateTimeZone.UTC);
        DateTime retval = dateTime.minusHours(hours);
        Timestamp retts = new Timestamp(retval.getMillis());
        retts.setNanos(ts.getNanos());/*from   w  w  w. j  a v a  2 s. c  om*/
        return retts;
    }
}

Related

  1. isValid(Timestamp validFrom, Timestamp validTo, Timestamp testDate)
  2. long2Timestamp(Long longValue)
  3. longFromTimestamp(Timestamp ts)
  4. max(Timestamp ts1, Timestamp ts2)
  5. maxTime(Timestamp dayTime)
  6. minusOneSecond(Timestamp now)
  7. newDate(Timestamp time)
  8. newTimestamp()
  9. newTimestamp(Date date)