Skip to content

[QUESTION] HH:mm:ss格式的时间无法解析为java.util.Date #2905

@KaiserDeng

Description

@KaiserDeng

`
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import java.util.Date;

@DaTa
public class TestOrder {

@JSONField(format = "HH:mm:ss")
private Date saleEndTime;

public static void main(String[] args) {
    String s = "{\"saleEndTime\": \"23:00:00\"}";
    TestOrder order = JSON.parseObject(s, TestOrder.class);
    System.out.println(JSON.toJSONString(order));
}

}
从fastjson升级到2.0.52后执行以上代码时,出现报错: Text '23:00:00' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to 23:00 of type java.time.format.Parsed`

请问我该如何解决该问题?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions