Java Date Now getCurrentToNextDaySecond()

Here you can find the source of getCurrentToNextDaySecond()

Description

get Current To Next Day Second

License

Open Source License

Declaration

public static Integer getCurrentToNextDaySecond() 

Method Source Code

//package com.java2s;
/**//  w  ww .ja v a 2 s. c  o  m
 * Copyright (c)2010-2011 Enterprise Website Content Management System(EWCMS), All rights reserved.
 * EWCMS PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * http://www.ewcms.com
 */

import java.text.SimpleDateFormat;

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

public class Main {

    public static Integer getCurrentToNextDaySecond() {
        try {
            Date current = new Date(Calendar.getInstance().getTime().getTime());

            Calendar calendar = Calendar.getInstance();
            current.setTime(current.getTime());

            calendar.add(Calendar.DATE, 1);
            SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd");
            Date nextDay = simple.parse(simple.format(calendar.getTime()));

            Long interval = (nextDay.getTime() - current.getTime() - 1) / 1000;

            return interval.intValue();
        } catch (Exception e) {
            return -1;
        }
    }
}

Related

  1. getCurrentTimestampString()
  2. getCurrentTimeStr()
  3. getCurrentTimeStr()
  4. getCurrentTimeString(String format)
  5. getCurrentTimeString(String pattern)
  6. getCurrentUnixTime()
  7. getCurrentUTCDate()
  8. getCurrentUtcDate()
  9. getCurrentUTCSeconds(Date current)