Java TimeUnit Usage getTomorrowTimestamp()

Here you can find the source of getTomorrowTimestamp()

Description

get Tomorrow Timestamp

License

Open Source License

Return

Unix timestamp of tomorrow midnight in seconds

Declaration

public static long getTomorrowTimestamp() 

Method Source Code

//package com.java2s;
/*/*  w ww  .j a va2s  .  com*/
 * Copyright ? R?gion Nord Pas de Calais-Picardie,  D?partement 91, R?gion Aquitaine-Limousin-Poitou-Charentes, 2016.
 *
 * This file is part of OPEN ENT NG. OPEN ENT NG is a versatile ENT Project based on the JVM and ENT Core Project.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation (version 3 of the License).
 *
 * For the sake of explanation, any module that communicate over native
 * Web protocols, such as HTTP, with OPEN ENT NG is outside the scope of this
 * license and could be license under its own terms. This is merely considered
 * normal use of OPEN ENT NG, and does not fall under the heading of "covered work".
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

import java.util.Calendar;

import java.util.concurrent.TimeUnit;

public class Main {
    /**
     * @return Unix timestamp of tomorrow midnight in seconds
     */
    public static long getTomorrowTimestamp() {
        // Get tomorrow by adding one day to current time
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DAY_OF_MONTH, 1);

        // Set time to midnight
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);

        return TimeUnit.SECONDS.convert(cal.getTimeInMillis(), TimeUnit.MILLISECONDS);
    }
}

Related

  1. getTimeFormat(final long time)
  2. getTimeForS3URL()
  3. getTimeInMillis(String str)
  4. getTimeString(long millis)
  5. getTimezoneOffset(TimeZone timeZone)
  6. getUnit(long nanos)
  7. getValidityAsString(Date endDate)
  8. getWithTimeout(final Future future)
  9. humanizeTime(long hours, long minutes, long seconds)