Java转换Json日期/Date(1487053489965+0800)/格式以及js时间格式 Tue Feb 14 2017 14:06:32 GMT+0800...

本文介绍如何使用Java将特殊格式的日期字符串转换为标准的'yyyy-MM-dd'格式。通过两个示例,展示了如何处理带有时间戳和特定字符的日期字符串,并使用SimpleDateFormat类进行格式化。

/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));

    }

转载于:https://www.cnblogs.com/1024zy/p/6397504.html

[root@VM-20-16-opencloudos ~]# curl -v https://restapi.amap.com/v3/ip?key=3fcd190efd00656eab3b21cd64ad676c * Trying 106.11.43.113... * TCP_NODELAY set * Connected to restapi.amap.com (106.11.43.113) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-ECDSA-AES256-GCM-SHA384 * ALPN, server accepted to use http/1.1 * Server certificate: * subject: C=CN; ST=ZheJiang; L=HangZhou; O=Alibaba (China) Technology Co., Ltd.; CN=*.amap.com * start date: Feb 6 06:02:02 2025 GMT * expire date: Mar 10 03:21:00 2026 GMT * subjectAltName: host "restapi.amap.com" matched cert's "*.amap.com" * issuer: C=BE; O=GlobalSign nv-sa; CN=GlobalSign GCC R3 OV TLS CA 2024 * SSL certificate verify ok. > GET /v3/ip?key=3fcd190efd00656eab3b21cd64ad676c HTTP/1.1 > Host: restapi.amap.com > User-Agent: curl/7.61.1 > Accept: */* > < HTTP/1.1 200 OK < Server: Tengine < Date: Tue, 27 May 2025 06:10:28 GMT < Content-Type: application/json;charset=UTF-8 < Content-Length: 96 < Connection: close < gsid: 033003229136174832622862100034040263967 < sc: 0.004 < Access-Control-Allow-Origin: * < Access-Control-Allow-Methods: * < Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,key,x-biz,x-info,platinfo,encr,enginever,gzipped,poiid < * Closing connection 0 * TLSv1.2 (OUT), TLS alert, close notify (256): {"status":"1","info":"OK","infocode":"10000","province":[],"city":[],"adcode":[],"rectangle":[]}
05-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值