在配置文件中全局的配置
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
所有使用到时间格式的地方都会转换为这种格式的
各种标准时间
https://ahuigo.github.io/b/c/shell-time#/
格林威治标准时间GMT
含义:「格林威治标准时间」(Greenwich Mean Time,简称G.M.T.)以伦敦格林威治的子午线为基线,以地球自转为标准,全球都以此标准设定时间。
以下几个时间相同,但用于不同的时区/地区。
Wed Aug 14 08:21:05 GMT 2013 //标准GMT时间
Wed Aug 14 16:21:05 GMT+8 2013 //东8区,即我们的北京时间
Wed Aug 14 03:21:05 GMT-5 2013 //西5区,美国和加拿大时间
协调世界时间UTC
由于地球每天的自转是有些不规则的,而且正在缓慢减速,因此格林威治时间已经不再被作为标准时间使用。现在的标准时间,是由原子钟报时的协调世界时(UTC: Coordinated Universal Time)。UTC比GMT更精确严谨。
Wed Aug 14 08:21:05 UTC 2013 //标准UTC时间
Wed Aug 14 16:21:05 UTC+8 2013 //东8区,即我们的北京时间
Wed Aug 14 03:21:05 UTC-5 2013 //西5区,美国和加拿大时间
常识:
国际原子时的误差为每日数纳秒
对我们日常所使用的时间工具而言,UTC和GMT时间没有区别。
ISO8601
moment.defaultFormat is the ISO8601 format YYYY-MM-DDTHH:mm:ssZ
ISO8601:
new Date("2016-01-01 11:13:00Z"); +0区
new Date("2016-01-01T11:13:00Z"); +0区
new Date("2016-01-01 11:13:00+08"); +8区
new Date("2016-01-01 11:13:00+0800"); +8区
new Date("2016-01-01T11:13:00+08:00"); +8区
new Date("2016-01-01T11:13:00.333+08:00"); +8区
new Date("2016-01-01"); +0区(默认)
new Date("2016-01-01 11:13:00"); +8区(默认)
new Date("October 13, 1975 11:13:00"); +8区(默认)
CST
CST是时区缩写,可以指下列的时区:
澳洲中部时间,Central Standard Time (Australia)
中部标准时区(北美洲),Central Standard Time (North America)
北京时间,China Standard Time
古巴标准时间,Cuba Standard Time,参见北美东部时区
建议不要使用CST时间,对于以下时间,你可能不知道它到底是北京时间,还是其它时间:
Wed Aug 14 08:21:05 CST 2013 //北京、北美中部、古巴、澳洲中部?Who knows?
CST 转北京时间
在需要转换日期格式的字段上添加注解com.fasterxml.jackson.annotation.JsonFormat
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
日期格式化 YYYYMMdd 与 yyyyMMdd 的区别
大写的 YYYY 表示这一天所在的周 所在的年份,也就是说如果当前周跨年了,这个获取到的就有问题。
日期格式化 yyyy-MM-dd HH:mm:SS 与 yyyy-MM-dd HH:mm:ss 的区别
HH 表示按 24 小时格式返回
SS 表示毫秒?
用小写的 ss 表示秒。
select d.queue,
count(*) as total
from gbl_loan a
join gbl_loan_type_dictionary b on a.loan_source = b.id and a.channel_id = b.channel_id
join gbl_collection_case c on c.loan_id = a.id
join gbl_assignment d on c.id = d.collection_id
where a.loan_source = #{loanSourceId}
and a.active = 1
and c.active = 1
and b.tenant = #{tenant}
and d.queue = #{queue}
and d.agentId is not null
<![CDATA[
and a.created_time > #{reportStartDate}
and a.created_time < #{reportEndDate}
]]>