在java里,时间实际上是用一个long表示的(8 bytes = 64 bits)。Date类的 getTime()方法:public long getTime()Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object. Returns:
the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date.
the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this date.
解决方案 »
- struts2文件上传 File转Byte[]时报异常
- servlet用Httpclient模拟登录出错求帮助=,=谢谢
- JDK6支持servlet2.4吗?
- DRP和OA
- DB2中有表,程序里也写模式名了,但是还是报找不到表?
- web 文件路径问题(系统找不到指定的路径。)
- 如何获取数据库的名字???
- 连接不上数据库
- jsp里在用两个input,每个里面分别输入不同的查询条件,安确定查询,怎么区分开它们
- 求助验证码无法显示问题
- 在线等:关于<jsp:plugin标签的问题 各位帮帮忙
- 新开 ++ Sql Server 数据库高级编程技术者交流群 ++ ,欢迎大家的加入共同讨论```````````
我用了以下的方法
Calendar date = Calendar.getInstance();
int currentHour=date.get(Calendar.HOUR_OF_DAY );//当前时间
int currentMinute=date.get(Calendar.MINUTE);
int currentSecond=date.get(Calendar.SECOND);
currentHour=(currentHour * 3600 + currentMinute*60 + currentSecond/60)
----------------------
若转换位 秒,currentSecond 除以60就不对了。
而且,不如这个省事:Calendar date = Calendar.getInstance();
int currentTime = date.getTime().getTime()/1000; // 毫秒数 转换位 秒数