Java AtomicLong getTomorrowTime()

Here you can find the source of getTomorrowTime()

Description

Returns the first millisecond of tomorrow.

License

Open Source License

Return

tomorrow time.

Declaration

public static long getTomorrowTime() 

Method Source Code


//package com.java2s;
// the terms of the GNU General Public License as published by the Free Software Foundation;

import java.util.Calendar;

import java.util.GregorianCalendar;

import java.util.concurrent.atomic.AtomicLong;

public class Main {
    private static final AtomicLong TOMORROW = new AtomicLong(-1);

    /**/*from ww  w.j  a va  2s. com*/
     * Returns the first millisecond of tomorrow.
     *
     * @return tomorrow time.
     */
    public static long getTomorrowTime() {
        final long current = System.currentTimeMillis();

        synchronized (TOMORROW) {
            if (current > TOMORROW.get()) {
                GregorianCalendar cal = new GregorianCalendar();
                cal.add(Calendar.DATE, 1);
                cal.set(Calendar.HOUR_OF_DAY, 0);
                cal.set(Calendar.MINUTE, 0);
                cal.set(Calendar.SECOND, 0);
                cal.set(Calendar.MILLISECOND, 0);
                TOMORROW.set(cal.getTimeInMillis());
            }
        }

        return TOMORROW.get();
    }
}

Related

  1. getNowMicrosUtc()
  2. getRAMUniqueID()
  3. getRandomTopicName()
  4. getSequenceNumber()
  5. getTempDirName()
  6. getTrackedAllocationStatus()
  7. getUniqueURIString()
  8. greaterAndSet(long value, AtomicLong atomicValue)
  9. isAtomicLong(final N number)