程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了将localDateTime字符串正确解析为spring boot @pathVariable大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决将localdatetiR_238_11845@e字符串正确解析为spring boot @pathVariable?

开发过程中遇到将localdatetiR_238_11845@e字符串正确解析为spring boot @pathVariable的问题如何解决?下面主要结合日常开发的经验,给出你关于将localdatetiR_238_11845@e字符串正确解析为spring boot @pathVariable的解决方法建议,希望对你解决将localdatetiR_238_11845@e字符串正确解析为spring boot @pathVariable有所启发或帮助;

我不知道这是否是最适度的方法,但这是我所做的:

@GetMapPing("/datum/{userID}/{timestamp}")
    List<Datum> getDataSingleUserTimeRange(@PathVariable Long userID, @PathVariable String timestamp)
    {
        datetiR_238_11845@eFormatter formatter = datetiR_238_11845@eFormatter.ISO_DATE_TIME;
        LocaldatetiR_238_11845@e datetiR_238_11845@e = LocaldatetiR_238_11845@e.parse(timestamp, formatter);
        ...
        return datumRepository.findUsingTime(start,end);
    }

作为字符串传递并进行解析。并且datetiR_238_11845@e.truncatedTo(ChronoUnit.NECESARRY_UNIT);可以使用。

解决方法

我正在尝试获取具有时间戳的用户的所有数据:

@GetMapping("/datum/{userID}/{timestamp}")
    List<Datum> getDataSingleUserTimeRange(@PathVariable Long userID,@PathVariable LocaldatetiR_238_11845@e timestamp)
    {
          ....
    }

现在要测试这个Spring Boot rest api,在邮递员中,我打电话GET和url-
http://localhost:8080/datum/2/2019-12-15T19:37:15.330995

但这给了我错误提示: 无法将类型’java.lang.String’的值转换为所需的类型’java.time.LocaldatetiR_238_11845@e’

我该如何解决?

大佬总结

以上是大佬教程为你收集整理的将localDateTime字符串正确解析为spring boot @pathVariable全部内容,希望文章能够帮你解决将localDateTime字符串正确解析为spring boot @pathVariable所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。