java:获取今天还剩下多少秒

思路:

1.获取当前时间
2.获取当前时间的下一天的开始时间
3.两者相减

    public static int getSeconds(){
        Calendar curDate = Calendar.getInstance();
        Calendar tommorowDate = new GregorianCalendar(curDate
                .get(Calendar.YEAR), curDate.get(Calendar.MONTH), curDate
                .get(Calendar.DATE) + 1, 0, 0, 0);
        return (int)(tommorowDate.getTimeInMillis() - curDate .getTimeInMillis()) / 1000;
    }

你可能感兴趣的:(java:获取今天还剩下多少秒)