a date object represents a precise moment in time, down to the millisecond. dates are represented as a long that counts the number of milliseconds since midnight, january 1, 1970, greenwich mean time.
to create a date object for the current date and time use the noargs date() constructor like this: 【程序编程相关:Shit? Happens, Part 】
does this have a year 2000 problem? if so in what year? 【推荐阅读:面向对象设计五大原则(2)】
to create a date object for a specific time, pass the number of milliseconds since midnight, january 1, 1970, greenwich meantime to the constructor, like this: 【扩展信息:几个String对象?】
date now = new date();
date midnight_jan2_1970 = new date(24l*60l*60l*1000l);
you can return the number of milliseconds in the date as a long, using the gettime() method. for example, to time a block of code, you might do this
... 下一页