Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

250
Visualizações
Java 8 DateTimeFormatter parse fails for ISO dates far in future

I encountered an issue where DateTimeFormatter.ISO_DATE_TIME where date cannot be parsed if year is more then 9999. I was looking for a bug report or to understand what I am doing wrong. Also - JodaTime parse works for the same string. Java version - 8. This test fails:

    public void testParseFarInTheFuture()
    {
        String str = "10000-04-11T01:24:55.887-03:56";

        DateTimeFormatter.ISO_DATE_TIME.parse(str);
    }

Same test with year 9999 works.

Am I doing something wrong or is there a bug?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Prepend +

  • Years with more than four digits are expected to have a leading PLUS SIGN character (+) for positive years (AD).
  • Negative years (BC) with any count of integers always lead with a MINUS SIGN (-).

The java.time classes generally follow the rules laid down in the ISO 8601 standard. See Wikipedia page on handling years in ISO 8601.

Code:

OffsetDateTime ldt = OffsetDateTime.parse( "+10000-04-11T01:24:55.887-03:56" ) ;

See this code run live at IdeOne.com.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda