Created
September 12, 2015 18:29
-
-
Save robsongomes/0e1fee0b4a6638311659 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.LocalDate; | |
import java.time.Month; | |
import java.time.Period; | |
import java.time.temporal.ChronoUnit; | |
public class PeriodTest { | |
public static void main(String[] args) { | |
LocalDate hoje = LocalDate.now(); | |
LocalDate rio16 = LocalDate.of(2016, Month.AUGUST, 5); | |
//Calculando o perido em Anos, Meses e Dias | |
Period periodoAteRio16 = hoje.until(rio16); | |
System.out.printf("Faltam %d meses e %d dias para as Olímpiadas do Rio 16%n", | |
periodoAteRio16.getMonths(), periodoAteRio16.getDays()); | |
//Calculando em dias abosolutos | |
System.out.printf("Faltam %d dias para as Olímpiadas do Rio 16%n", | |
hoje.until(rio16, ChronoUnit.DAYS)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment