atOffset using map

Asked

Viewed 33 times

2

    private OffsetDateTime getDataDistribuicao() {
    return Optional.ofNullable(this.getPaginaInfoGerais())
            .map(page -> page.<HtmlTableCell>getFirstByXPath(XPATH_CEL_DATA_DISTRIBUICAO))
            .map(HtmlTableCell::getTextContent)
            .map(str -> replaceAndTrim(str))
            .map(str -> getDataDistribuicao(str))
            .map(str -> LocalDateTime.parse( str, DateTimeFormatter.ofPattern(PATTERN_DATA_HORA)))
            .map(LocalDateTime::atOffset(ZoneOffset.UTC));
}

At last map i get the bug:

non Static method cannot be referenced from a Static context

What to do?

  • atOffset is not static method, and you are trying to access it as static.

1 answer

0


The way I found it was this, it worked:

    private OffsetDateTime getDataDistribuicao() {
    return Optional.ofNullable(this.getPaginaInfoGerais())
            .map(page -> page.<HtmlTableCell>getFirstByXPath(XPATH_CEL_DATA_DISTRIBUICAO))
            .map(HtmlTableCell::getTextContent)
            .map(str -> replaceAndTrim(str))
            .map(str -> getDataDistribuicao(str))
            .map(str -> LocalDateTime.parse( str, DateTimeFormatter.ofPattern(PATTERN_DATA_HORA)).atOffset(ZoneOffset.UTC))
            .orElse(null);
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.