Created
April 27, 2018 11:54
-
-
Save Marlysson/639681fedaee60c81fa4fcf5b18734e8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Calendar dataAtual = Calendar.getInstance(); | |
Calendar anterior = Calendar.getInstance(); | |
anterior.set(Calendar.MONTH,Calendar.APRIL); | |
anterior.set(Calendar.YEAR, 2018); | |
anterior.set(Calendar.DAY_OF_MONTH, 25); | |
DateFormat formato = new SimpleDateFormat("dd/MM/yyyy"); | |
System.out.println("Anterior: " + formato.format(anterior.getTime())); | |
System.out.println("Atual: " + formato.format(dataAtual.getTime()) + "\n"); | |
if ( anterior.before(dataAtual.getTime())) { | |
System.out.println("Antes"); | |
}else { | |
System.out.print("Depois"); | |
} | |
//Saída no console | |
Anterior: 25/04/2018 | |
Atual: 27/04/2018 | |
Depois |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment