更新时间:2023-02-03 08:46:56
如果你使用 Date
对象的 getTime()
你会得到毫秒的时间.无需使用 Timestamp
即可获得结果.
If you use getTime()
of Date
object you will get time in millisecond.
No need to use Timestamp
to get your result.
String str_date="13-09-2011";
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
Date date = (Date)formatter.parse(str_date);
System.out.println("Today is " +date.getTime());
上面的代码会打印出你需要的类似 1312828200000
的东西,这是长值.
The above code will print something like 1312828200000
you need and this is long value.