• 字符串:"2016-09-21T18:57:50+08:00[Asia/Chungking]" 转Date


    public static void main(String[] args) throws Exception {

    Date date1 = new Date();
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
    String str1 = df.format(date1);
    System.out.println("yyyy-MM-dd'T'HH:mm:ssZ:"+str1);

    String str2="2016-10-10T14:54:25+0800";
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
    Date date2 = sdf.parse(str2);
    System.out.println(date2);

    Date date3 = new Date();
    SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
    String str3 = df2.format(date3);
    System.out.println("yyyy-MM-dd'T'HH:mm:ssXXX:"+str3);

    String str4="2016-10-10T14:54:25+08:00";
    SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
    Date date4 = sdf2.parse(str4);
    System.out.println(date4);

    String str5="2016-09-21T18:57:50+08:00[Asia/Chungking]";
    SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
    Date date5 = sdf3.parse(str5);
    System.out.println("str5:"+date5);
    System.out.println(DateToZonedDateTimeConverter.INSTANCE.convert(date5));
    }

  • 相关阅读:
    MySQL 连接的使用
    MySQL GROUP BY 语句
    MySQL 排序
    MySQL UNION 操作符
    MySQL LIKE 子句
    MySQL DELETE 语句
    MySQL UPDATE 更新
    MySQL WHERE 子句
    php MySQL 查询数据
    MySQL 插入数据
  • 原文地址:https://www.cnblogs.com/2016-10-10/p/5946674.html
Copyright © 2020-2023  润新知