时间格式 2016-08-15T16:00:00.000Z
我修改的时间是2016-08-16(转换成Date后默认为2016-08-16 00:00:00),而我得到的时间却是2016-08-15T16:00:00.000Z
联想到我们当前的时区是+8区 而16+8正好也是第二天0点,估计这000Z这货多半是和时区相关的。
果不其然,百度了一下发现,原来这个就是UTC 通用标准时,以z来标识。既然知道了问题所在,那么我们就可以有相应的解决方法了。
java后台得到的时间是:String date = “2016-08-15T16:00:00.000Z”
传入yyyy-MM-dd格式,转换成Date类型默认hh:mm:ss为00:00:00
String now = "2016-08-16";
DateFormat format2 = new SimpleDateFormat("yyyy-MM-dd");
Date date2 = format2.parse(now);
System.out.println(date2);
输出:
Tue Aug 16 00:00:00 CST 2016
将2016-08-15T16:00:00.000Z 时间格式转换成Date类型格式
String date = "2016-08-15T16:00:00.000Z";
date = date.replace("Z", " UTC");
System.out.println(date);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS Z");
Date d = format.parse(date);
System.out.println(d);
输出:
2016-08-15T16:00:00.000 UTC
Tue Aug 16 00:00:00 CST 2016
结论:与时区相关
时间格式 2016-08-15T16:00:00.000Z的更多相关文章
- java时间格式转化(毫秒 to 00:00)
把秒数转换为%d:%02d:%02d 格式 private String stringForTime(int timeSec) { int totalSeconds = timeSec; int se ...
- python:时间格式转化
1.获取秒级时间戳与毫秒级时间戳.微秒级时间戳 import time import datetime t = time.time() print (t) #原始时间数据 print (int(t)) ...
- python 字符串和时间格式(datetime)相互转换-
2019-03-17 11:00:00格式转化 import datetime # str转时间格式: dd = '2019-03-17 11:00:00' dd = datetime.datetim ...
- 前台时间格式 2019-03-09T16:00:00.000Z
问题描述: 本想在前台把字符串格式的日期(2019-03-09)转换成日期格式(2019-03-09 00:00:00),但当把这个参数传到后台去后却变成了2019-03-08T16:00:00.00 ...
- c# 时间格式处理,获取格式: 2014-04-12T12:30:30+08:00
C# 时间格式处理,获取格式: 2014-04-12T12:30:30+08:00 一.获取格式: 2014-04-12T12:30:30+08:00 方案一:(局限性,当不是当前时间时不能使用) ...
- 将时间 '2018-08-06T10:00:00.000Z' 格式转化为本地时间
参考:https://blog.csdn.net/sxf_123456/article/details/81582964 参考模板: from datetime import datetime, ti ...
- 时间 '2018-08-06T10:00:00.000Z' 格式转化为本地时间(转)
原文:https://blog.csdn.net/sxf_123456/article/details/81582964 from datetime import datetime,timedelta ...
- js new Date("2016-07-01 08:00:00") 格式在IE内核浏览器中显示NaN的问题
js new Date("2016-07-01 08:00:00") 格式在IE内核浏览器中显示NaN的问题 废话就不多了,var dd = new Date("2016 ...
- Mysql 时间格式默认空串 '0000-00-00 00:00:00' select抛出异常的解决方法
Mysql 时间格式默认插入值为空时,会以'0000-00-00 00:00:00'填充,这时如果select时会抛出SQLExecption如下: java.sql.SQLException: Va ...
随机推荐
- shell-note-1-基础篇
1. Shell is a program written in C. It provides an interface for users to access to the service of o ...
- LeetCode 673. Number of Longest Increasing Subsequence
Given an unsorted array of integers, find the number of longest increasing subsequence. Example 1: I ...
- Ubuntu 14.04在虚拟机上的桥接模式下设置静态IP
1.虚拟机--->虚拟机设置 将虚拟机设置为桥接模式 2.查看window 网卡以及IP信息 cmd下输入 ipconfig -all 可以看到,我的网卡为Realtek PCIe GBE Fa ...
- prometheus + mysqld_exporter + grafana 实现对mysql db的监控
https://blog.csdn.net/hfut_wowo/article/details/78536022 1.参考这篇博文2.博主的用的是windows版本 prometheus-2.5.0- ...
- [SQL server] IF ELSE 和 CASE WHEN 的用法
/*判断一个数如果大于10,按10统计,如果小于0,按0统计*/ --方法a DECLARE @AA INT SET @AA=15 IF @AA>10 SELECT 10 ELSE IF @AA ...
- EasyUI 加载Tree
function LoadTree(result) { mainMenu = $('#mainMenu').tree({ url: "/ajax/GetTreeJson.ashx" ...
- POJ 1330:Nearest Common Ancestors【lca】
题目大意:唔 就是给你一棵树 和两个点,问你这两个点的LCA是什么 思路:LCA的模板题,要注意的是在并查集合并的时候并不是随意的,而是把叶子节点合到父节点上 #include<cstdio&g ...
- K-th Number(poj 2104)
题意:静态第K大 #include<cstdio> #include<iostream> #include<cstring> #define N 200010 #d ...
- 转 Linux中常用操作命令
http://blog.csdn.net/ljianhui/article/details/11100625 初窥Linux 之 我最常用的20条命令 玩过Linux的人都会知道,Linux中的命令的 ...
- [UIScreen mainScreen].applicationFrame与[UIScreen mainScreen].bounds区别
[UIScreen mainScreen].applicationFrame与[UIScreen mainScreen].bounds区别: applicationFrame会自动判断是否存在状态栏, ...