java 日期差 实现(×分钟前)功能
今天经理让写一个,根据信息上传时间,显示,?分钟前,?小时前,?天前,类似qq空间发表的心情日期;
用了一个自我感觉笨的方法,不过还是实现了,呵呵呵
public static String getCompareTime(String filetime){
//返回的字符串
String retStr ="";
//传入的日期是2008-9-12等,不作处理
if(filetime.indexOf("-")>0){
retStr =filetime;
}
else{
try{
DateFormat day = new SimpleDateFormat("dd");
DateFormat hour = new SimpleDateFormat("HH");
DateFormat minute = new SimpleDateFormat("mm");
Date today = new Date();
//得到当前时间的日,小时,分钟
int nowDay =Integer.parseInt(day.format(today));
int nowHour =Integer.parseInt(hour.format(today));
int nowMinute =Integer.parseInt(minute.format(today));
// System.out.println("nowDay:"+nowDay);
// System.out.println("nowDay:"+nowHour);
// System.out.println("nowDay:"+nowMinute);
//格式化传入的字符串
DateFormat df = new SimpleDateFormat("yy/MM/dd HH:mm:ss");
Date dataTime = df.parse(filetime);
//得到传入时间的日,小时,分钟
int dataDay =Integer.parseInt(day.format(dataTime));
int dataHour =Integer.parseInt(hour.format(dataTime));
&n
相关文档:
一般,有3种使用锁进行同步的方法
a.方法同步,例如public synchronized void xxx()...
b.静态方法同步,例如public static synchronized void xxx()...
c.程序块同步,例如
...
&n ......
Java NIO类库Selector机制解析(上)
赵锟 陈皓
http://blog.csdn.net/haoel
一、 前言
自从J2SE 1.4版本以来,JDK发布了全新的I/O类库,简称NIO,其不但引入了全新的高效的I/O机制,同时,也引入了多路复用的异步模式。NIO的包中主要包含了这样几种抽象数据类型:
......
public class OperatExcel
{
private File file = new File(ParamenterInit.SRCEXCELPATH);
private File outfile = new File(ParamenterInit.DESTEXCELPATH);
private static String sheetName = ParamenterInit.SHEETNAME;
  ......
Java下的一个简单易用的反编译工具jad
,
可以很方便的将.class反编译为.Java.
一、基本用法
Usage:jad
[option(s)]
直接输入类文件名,且支持通配符,如下所示。
c:\Java\>jad
example1.class
c:\Java\>jad
*.class
结果是将example1.class反编译为example1.jad
。将
example1.jad
改为exampl ......