如果前端给后端传递的JSON对象中,有个日期类型的属性,而且后端对应的实体类的属性直接使用对应的Date的话,可能会存在接收过来的时间只有年月日,后面的时分秒直接被丢失。原因如下:
public static long parse(String s) {
int year = Integer.MIN_VALUE;
int mon = -1;
int mday = -1;
int hour = -1;
int min = -1;
int sec = -1;
int millis = -1;
int c = -1;
int i = 0;
int n = -1;
int wst = -1;
int tzoffset = -1;
int prevc = 0;
syntax:
{
if (s == null)
break syntax;
int limit = s.length();
while (i < limit) {
c = s.charAt(i);
i++;
if (c <= ' ' || c == ',')
continue;
if (c == '(') { // skip comments
int depth = 1;
while (i < limit) {
c = s.charAt(i);
i++;
if (c == '(') depth++;
else if (c == ')')
if (--depth <= 0)
break;
}
continue;
}
if ('0' <= c && c <= '9') {
n = c - '0';
while (i < limit && '0' <= (c = s.charAt(i)) && c <= '9') {
n = n * 10 + c - '0';
i++;
}
if (prevc == '