如下几组数表示的时间
ae4f0950 2012年07月20日 20:31:42
ae4f0a50 2012年07月21日 14:43:58
00000000 1970年01月01日 08:00:00
ffffffff 2000年02月03日 04:37:51
求指点怎样编写一个把日期和时间相互转换的程式啊!
ae4f0950 2012年07月20日 20:31:42
ae4f0a50 2012年07月21日 14:43:58
00000000 1970年01月01日 08:00:00
ffffffff 2000年02月03日 04:37:51
求指点怎样编写一个把日期和时间相互转换的程式啊!
System.out.printf("0x%08X\n", timer);如果希望得到字符串,可以:
String hex = "0x" + Long.toHexString(timer);
import java.util.Map;public class Test {
public static void main(String[] args) throws Exception {
Map<String,String> map = new HashMap<String,String>();
map.put("ae4f0a50","2012年07月21日 14:43:58");
map.put("2012年07月21日 14:43:58","ae4f0a50");
map.put("00000000","1970年01月01日 08:00:00");
map.put("1970年01月01日 08:00:00","00000000");
System.out.println("ae4f0a50 --> " + map.get("ae4f0a50"));
System.out.println("2012年07月21日 14:43:58 --> " + map.get("2012年07月21日 14:43:58"));
}
}
不知道楼主是不是这个意思。
00000000 1970年01月01日 08:00:00
ffffffff 2000年02月03日 04:37:51
你这两个风马牛不相及的结果是怎么计算出来的?
long timer = new Date().getTime() / 1000;
System.out.printf("0x%08X\n", timer); String hex = "0x" + Long.toHexString(timer);应该是可以满足你要求的。
+1再用Date构造方法弄一下就成了.