小编sur*_*day的帖子

将日期从ISO 8601 Zulu字符串转换为Java 8中的java.time.Instant

我想将字符串日期格式转换为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字符串到日期的转换,但不起作用.

java datetime datetime-format java-8 java.time.instant

5
推荐指数
2
解决办法
2088
查看次数

我们如何在java8中的DoubleSummaryStatistics对象中自定义count,avg,sum,min和max的顺序

我按以下格式获得低于输出,这是我认为的默认值.

{"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)

java java-8

5
推荐指数
1
解决办法
83
查看次数

ConcurrentHashMap中的concurrencyLevel

如果ConcurrentHashMap大小增加,concurrencyLevel会是什么?

假设ConcurrentHashMap的初始容量为16.而默认的concurrencyLevel为16.如果容量在一段时间后按负载因子增加,现在增加的容量为28.在这种情况下,concurrencyLevel是什么?

继续使用这些链接以及 ConcurrentHashMap中的Segmentation在ConcurrentHashMap中修改值但仍然不清楚.

提前致谢.

java collections concurrenthashmap

4
推荐指数
1
解决办法
94
查看次数

在“ Spring Tool Suite版本:3.9.6.RELEASE”中,“显示”视图在任何角度都不可见

窗口->显示视图->其他->键入“显示”。但显示视图不会到来在此处输入图片说明

我已经在debug和spring上进行了复位,但是仍然看不到显示。

eclipse perspective spring-tool-suite spring-tools-4

3
推荐指数
1
解决办法
552
查看次数