設置此Date對象以表示一個時間點,即1970年1月1日00:00:00 GMT之后的時間毫秒。
public void setTime(long time)
time - 毫秒數(shù)。
沒有
下面是一個使用這個方法的例子 -
class Example { static void main(String[] args) { Date olddate = new Date("05/11/2015"); Date newdate = new Date("05/12/2015"); Date latestdate = new Date(); olddate.setTime(10000); newdate.setTime(10000); latestdate.setTime(10000); System.out.println(olddate.toString()); System.out.println(newdate.toString()); System.out.println(latestdate.toString()); } }
當我們運行上面的程序,我們將得到以下結果 -
Thu Jan 01 04:00:10 GST 1970 Thu Jan 01 04:00:10 GST 1970 Thu Jan 01 04:00:10 GST 1970
更多建議: