Calculando períodos de data com Java 8

From Basef
Revision as of 18:02, 9 July 2017 by Admin (Talk | contribs) (Criou página com 'Exemplo: <source lang="java"> LocalDate olimpiadasRio = LocalDate.of(2016, Month.JUNE, 5); LocalDate hoje = LocalDate.now(); Period periodo = Period.between(hoje, olimpiadas...')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Exemplo:

LocalDate olimpiadasRio = LocalDate.of(2016, Month.JUNE, 5);
LocalDate hoje = LocalDate.now();
 
Period periodo = Period.between(hoje, olimpiadasRio);
System.out.println(periodo.getYears());
System.out.println(periodo.getMonths());
System.out.println(periodo.getDays());