Merge branch 'br-384' into develop
This commit is contained in:
@@ -15,6 +15,7 @@ import lombok.NoArgsConstructor;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
@@ -54,7 +55,7 @@ public class DSLQueryRequestParam extends CommonRequestParam implements Serializ
|
||||
public DateTime getStart() {
|
||||
if (this.intervals != null && this.intervals.size() == 1) {
|
||||
String[] split = this.intervals.get(0).split("/");
|
||||
return DateUtil.parse(split[0]);
|
||||
return DateUtil.parse(split[0]).setTimeZone(TimeZone.getDefault());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -63,7 +64,7 @@ public class DSLQueryRequestParam extends CommonRequestParam implements Serializ
|
||||
public DateTime getEnd() {
|
||||
if (this.intervals != null && this.intervals.size() == 1) {
|
||||
String[] split = this.intervals.get(0).split("/");
|
||||
return DateUtil.parse(split[1]);
|
||||
return DateUtil.parse(split[1]).setTimeZone(TimeZone.getDefault());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -102,8 +102,8 @@ public class LogQueryServiceImpl implements LogQueryService {
|
||||
DSLQueryContext dslQueryContextTemp = BeanUtil.copyProperties(requestParam, DSLQueryContext.class);
|
||||
List<String> intervals = dslQueryContextTemp.getIntervals();
|
||||
String[] split = intervals.get(0).split("/");
|
||||
DateTime start = DateUtil.parse(split[0]);
|
||||
DateTime end = DateUtil.parse(split[1]);
|
||||
DateTime start = DateUtil.parse(split[0]).setTimeZone(TimeZone.getDefault());
|
||||
DateTime end = DateUtil.parse(split[1]).setTimeZone(TimeZone.getDefault());
|
||||
|
||||
int seconds = Period.parse(granularity).toStandardSeconds().getSeconds();
|
||||
DateTime dateTime = DateUtil.offsetSecond(cursorEndTime, seconds);
|
||||
|
||||
@@ -1,34 +1,49 @@
|
||||
package com.mesalab.qgw.service;
|
||||
|
||||
import cn.hutool.core.date.DateException;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mesalab.GalaxyQGWApplicationTests;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
|
||||
@EnableAutoConfiguration
|
||||
public class DateFormatTest extends GalaxyQGWApplicationTests {
|
||||
private static final Log log = LogFactory.get();
|
||||
private final static ArrayList<String> dateTimeStrList = Lists.newArrayList();
|
||||
|
||||
static {
|
||||
dateTimeStrList.add("2021-08-13T14:20:18.992847200-04:00");
|
||||
dateTimeStrList.add("2023-03-15T01:57:58.865Z");
|
||||
dateTimeStrList.add("2018-10-01T10:00:00Z");
|
||||
dateTimeStrList.add("2023-03-15T01:57:58.865+08:00");
|
||||
@Test
|
||||
public void testDateParserTimeZoneJVM() {
|
||||
ArrayList<String> dateTimeStrList = Lists.newArrayList();
|
||||
dateTimeStrList.add("2000-01-01T00:00:00Z");
|
||||
dateTimeStrList.add("2000-01-01T00:00:00.865Z");
|
||||
dateTimeStrList.add("1999-12-31T20:00:00.992847200-04:00");
|
||||
dateTimeStrList.add("2000-01-01T08:00:00.865+08:00");
|
||||
try {
|
||||
for (String dateTimeStr : dateTimeStrList) {
|
||||
DateTime parse = DateUtil.parse(dateTimeStr).setTimeZone(TimeZone.getDefault());
|
||||
Assertions.assertEquals("2000-01-01 00:00:00", parse.toString());
|
||||
}
|
||||
} catch (DateException e) {
|
||||
throw new DateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDateParser() {
|
||||
public void testDateParserTimeZoneDefault() {
|
||||
List<String> dateTimeStrList = Lists.newArrayList();
|
||||
dateTimeStrList.add("2000-01-01T00:00:00Z");
|
||||
dateTimeStrList.add("2000-01-01T00:00:00.865Z");
|
||||
dateTimeStrList.add("2000-01-01T00:00:00.992847200-04:00");
|
||||
dateTimeStrList.add("2000-01-01T00:00:00.865+08:00");
|
||||
try {
|
||||
for (String dateTimeStr : dateTimeStrList) {
|
||||
log.info(String.valueOf(DateUtil.parse(dateTimeStr)));
|
||||
Assertions.assertEquals("2000-01-01 00:00:00", DateUtil.parse(dateTimeStr).toString());
|
||||
}
|
||||
} catch (DateException e) {
|
||||
throw new DateException(e);
|
||||
|
||||
Reference in New Issue
Block a user