本帖最后由 刘文超 于 2013-1-2 17:28 编辑
时间戳-->Date/Sting:- SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
- Long time=new Long(445555555);
- String d = format.format(time);
- Date date=format.parse(d);
- System.out.println("Format To String(Date):"+d);//Format To String(Date):1970-01-06 11:45:55
- System.out.println("Format To Date:"+date);//Format To Date:Tue Jan 06 11:45:55 CST 1970
复制代码 Date/String-->时间戳:- SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
- String time="1970-01-06 11:45:55";
- Date date = format.parse(time);
- System.out.print("Format To times:"+date.getTime());//Format To times:445555000
复制代码 |