/Date(1487053489965+0800)/用Java怎么转换成yyyy-MM-dd的格式
Tue Feb 14 2017 14:06:32 GMT+0800用Java怎么转换成yyyy-MM-dd的格式
跟普通的日期不太一样
public static void main(String[] args)
{ String str="/Date(1487053489965+0800)/"; str=str.replace("/Date(","").replace(")/",""); String time = str.substring(0,str.length()-5); Date date = new Date(Long.parseLong(time)); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); System.out.print(format.format(date)); }
public static void main(String[] args) throws ParseException { String datdString="Tue Feb 14 2017 14:06:32 GMT+0800"; datdString = datdString.replace("GMT", "").replaceAll("\\(.*\\)", ""); SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd yyyy hh:mm:ss z", Locale.ENGLISH); Date dateTrans = format.parse(datdString); System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(dateTrans)); }
时间: 2024-10-18 22:02:33