我想弄清楚如何在java中获取 future 日期剩余的毫秒数,以便我可以制作倒数计时器,例如:
long countdowntimer = futuredate - system.currentTimeMillis();
最佳答案
假设 futuredate
的类型为 Date
,您可以使用其 getTime()
方法获得一个 long
表示形式。
编辑:
SimpleDateFormat fmt = new SimpleDateFormat("EEE MMM dd yyyy",Locale.ENGLISH);
Date d = fmt.parse("Sat Feb 17 2012");
System.out.println((d.getTime() - System.currentTimeMillis() )/1000 + " seconds till " + d );
关于java - 用java处理 future 的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8426846/