我想将字符串日期格式转换为java.time.Instant
我在解析日期时遇到异常.
java.lang.IllegalArgumentException: Too many pattern letters: s
Run Code Online (Sandbox Code Playgroud)
我使用下面的代码进行转换,从String到date.
String string = "2018-07-17T09:59:51.312Z";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("YYYY-MM-DD'T'hh:mm:ss.sssZ", Locale.FRANCE);
LocalDate date = LocalDate.parse(string, formatter);
System.out.println(date);
Run Code Online (Sandbox Code Playgroud)
我想转换"timestamp":"2018-07-17T09:59:51.312Z"在YYYY-MM-DDThh:mm:ss.sssZUTC时区中以ISO 8601格式的格式时间.
检查Java字符串到日期的转换,但不起作用.
我按以下格式获得低于输出,这是我认为的默认值.
{"count":100,"sum":25640.13,"min":2.65,"max":483.91,"average":256.4013}
Run Code Online (Sandbox Code Playgroud)
但我想改变这种格式如下.
{"sum":"25640.13","avg":"256.40","max":"483.91","min":"2.65","count":100}
Run Code Online (Sandbox Code Playgroud)
下面我在java类中使用的代码.
@Override
public DoubleSummaryStatistics getStatistic() {
logger.info("Getting statistic");
Set<Entry<Long, Transaction>> endtrySet = statisticHistory.entrySet();
List<Double> amountList = new ArrayList<>();
for (Entry<Long, Transaction> entry : endtrySet) {
if (((entry.getValue().getDate())).isAfter(Instant.now().minusSeconds(windowInMs)))
amountList.add((entry.getValue().getAmount()).doubleValue());
}
return amountList.stream().mapToDouble((x) -> x).summaryStatistics();
}
Run Code Online (Sandbox Code Playgroud)
如何重新排列json格式?
为了更好的理解,用简单的语法粘贴上面的方法.示例代码方法..
public DoubleSummaryStatistics getStatisdtic() {
logger.info("Getting statistic");
Set<BigDecimal> endtrySet = null ; //= getting this from a other resource
List<Double> amountList = new ArrayList<>();
for (BigDecimal entry : endtrySet) {
amountList.add((entry).doubleValue());
}
return amountList.stream().mapToDouble((x) -> x).summaryStatistics();
}
Run Code Online (Sandbox Code Playgroud) 如果ConcurrentHashMap大小增加,concurrencyLevel会是什么?
假设ConcurrentHashMap的初始容量为16.而默认的concurrencyLevel为16.如果容量在一段时间后按负载因子增加,现在增加的容量为28.在这种情况下,concurrencyLevel是什么?
继续使用这些链接以及 ConcurrentHashMap中的Segmentation和在ConcurrentHashMap中修改值但仍然不清楚.
提前致谢.