Java时间计算陷阱
Java毫秒时间计算时,千万要注意int和long的使用,看下例,小心别踩了雷。
/**
* java时间计算(int和long要注意,一定要选择long)
* @author 崔卫兵
*
*/
public class TimeTester {
/**
* 计算几天前的毫秒数
* @param days
* @return
*/
public static long getBeginSpan(long now,int days){
long beginspan = now-60*60*24*days*1000;
return beginspan;
}
/**
* 计算几天前的毫秒数
* @param days
* @return
*/
public static long getBeginSpan2(long now,int days){
long lessThisLong = 60*60*24*days*1000l;
long beginspan = now-lessThis;
return beginspan;
}
/**
* 计算几天前的毫秒数
* @param days
* @return
*/
public static long getBeginSpan3(long now,int days){
int lessThisInt = 60*60*24*days*1000;
System.out.println("lessThis:"+lessThis);
long beginspan = now-lessThis;
return beginspan;
}
public static void main(String[] args) {
long now = System.currentTimeMillis();
System.out.println("now:"+now);
System.out.println("be
相关文档:
Java NIO API详解
在JDK
1.4以前,Java的IO操作集中在java.io这个包中,是基于流的阻塞(blocking)API。对于大多数应用来说,这样的API使用很方
便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来处理IO。从JDK 1.4起,NIO
API作为一个基于缓冲区,并能提供非阻塞(non-blo ......
本文来自CSDN博客:http://blog.csdn.net/xyk0830/archive/2007/11/06/1869638.aspx
命令行格式:
native2ascii.exe -[options] [inputfile [outputfile]]
其中:
-[options]表示命令开关,有两个选项可供选择:
-reverse:用Latin-1或Unicode编码把文件转换成本地编码格式
-encoding ......
在JSP里,获取客户端的IP地址的方法是:request.getRemoteAddr(),这种方法在大部分情况下都是有效的。但是在通过了Apache,Squid等反向代理软件就不能获取到客户端的真实IP地址了。
如果使用了反向代理软件,将http://192.168.1.110:2046/ 的URL反向代理为http://www.xxx.com/ 的URL时,用request.getRemoteAddr()方 ......
记得部门老大曾经说过,java的垃圾回收机制对于java体系结构的学习非常重要。这里将阅读的一些文献整理总结出来,记述java的几种垃圾回收算法。
垃圾回收算法有两个基本的问题:1.必须检测到垃圾对象。2.必须重新声明被垃圾对象占用的堆空间并且让堆空间可用。
可达性 ......
public class MyEclipseGen {
private static final String LL = "Decompiling this copyrighted software is a violation of both your license agreement and the Digital Millenium Copyright Act of 1998 (http://www.loc.gov/copyright/legislation/dmca.pdf). Under section 1204 of the DMCA, penalties range up ......