4时间转换

 

 

  /* 
将时间转换为时间戳String res="2013-01-21 15:10:20";SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");Date date;try {date = simpleDateFormat.parse(res);long ts = date.getTime();res = String.valueOf(ts);System.out.println(res);//1358752220000} catch (ParseException e) {// TODO 自动生成的 catch 块e.printStackTrace();}*//* 将时间戳转换为时间String res="1358752220000";SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");long lt = new Long(res);Date date = new Date(lt);res = simpleDateFormat.format(date);System.out.println(res);//1358752220000*/ /*  把Date型的字符串转换成特定格式的String类型SimpleDateFormat dateformat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ");String a=dateformat.format(new Date());System.out.println("时间:"+a);//时间:2019-07-08 13:02:30 */    

 


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部