Java Hour nextHour(Date date)

Here you can find the source of nextHour(Date date)

Description

next Hour

License

Open Source License

Declaration

public static Date nextHour(Date date) 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    static SimpleDateFormat minuteFormat = new SimpleDateFormat("mm");
    static SimpleDateFormat secondFormat = new SimpleDateFormat("ss");

    public static Date nextHour(Date date) {
        long now = date.getTime();
        int min = Integer.valueOf(minuteFormat.format(date));
        int sec = Integer.valueOf(secondFormat.format(date));

        long begin = now - min * 60 * 1000 - sec * 1000;
        long end = begin + 60 * 60 * 1000;
        return new Date(end);
    }/*  w ww  .  j  a va 2 s  .  c  o  m*/
}

Related

  1. HourNow()
  2. Hours()
  3. hours(int hours)
  4. hoursAndMinsToMilliseconds(int sign, int hours, int minutes)
  5. isHour(int hour)
  6. nextHour(int hour)
  7. resetHourMillisToZero(long millis)
  8. tomrrow(int hour, int minute, int second)