[英]How to convert JsonNode to Date using Java 8 function
Having a common interface with a method signature as below. 具有带有方法签名的通用接口,如下所示。
Function 功能
for long it is implemented as below 长期以来它实现如下
Function<JsonNode, Long> getMapping ()
{
return JsonNode::longValue;
}
How this can be implemented for JsnonNode to Date .There is no direct api to get Date from JsonNode. 如何实现JsnonNode to Date。没有直接的api从JsonNode获取Date。 JsonNode has a number and it is converted to Date as blow. JsonNode有一个数字,将其转换为Date作为打击。 Date d = new Date(1220227200L * 1000). 日期d =新日期(1220227200L * 1000)。 Would like to know how to do that conversion in the below method 想知道如何在以下方法中进行转换
Function<JsonNode, Date> getMapping ()
{
}
Just do your calculation in a lambda expression: 只需使用lambda表达式进行计算即可:
Function<JsonNode, Date> getMapping ()
{
return node -> new Date(node.longValue() * 1000);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.