Android Timestamp Get getTimestamp(Timestamp timestamp, int day, int hour, int minute)

Here you can find the source of getTimestamp(Timestamp timestamp, int day, int hour, int minute)

Description

get Timestamp

Declaration

public static Timestamp getTimestamp(Timestamp timestamp, int day,
            int hour, int minute) 

Method Source Code

//package com.java2s;

import java.sql.Timestamp;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class Main {
    public static Timestamp getTimestamp(Timestamp timestamp, int day,
            int hour, int minute) {
        Calendar calendar = new GregorianCalendar();
        if (timestamp != null) {
            calendar.setTimeInMillis(timestamp.getTime());
        } else {//w ww .j  a  v a 2 s  .c o m
            calendar = Calendar.getInstance();
        }
        calendar.add(Calendar.DATE, day);
        calendar.set(Calendar.HOUR, hour);
        calendar.set(Calendar.MINUTE, minute);
        return new Timestamp(calendar.getTimeInMillis());
    }

    public static Timestamp add(Date date, int calendarField, int amount) {
        if (date == null) {
            throw new IllegalArgumentException("The date must not be null");
        }
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(calendarField, amount);
        return new Timestamp(c.getTimeInMillis());
    }
}

Related

  1. getFirstOfYear(Timestamp t1)
  2. getFriendlyTimeStamp()
  3. getLastOfMonth(Timestamp t1)
  4. getLastOfYear(Timestamp t1)
  5. getRelativeTimeofTweet(String timeStamp)
  6. getWeekOfYear(Calendar cal, Timestamp ts)
  7. getTimeStamp()
  8. getTimestamp(Context context)