Created
March 14, 2016 16:34
-
-
Save victorvaz/46134fee7c54f557f4b6 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
package datanojava; | |
import java.text.DateFormat; | |
import java.util.Calendar; | |
import java.util.GregorianCalendar; | |
public class OperacoesComData { | |
public static void main (String[] args) { | |
// Cria um formatador para a data usando DateFormat: | |
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM); | |
Calendar gc = Calendar.getInstance(); | |
System.out.println(df.format(gc.getTime())); // 14/03/2016 | |
// Adiciona 10 dias: | |
gc.add((GregorianCalendar.DAY_OF_MONTH), 10); | |
System.out.println(df.format(gc.getTime())); // 24/03/2016 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment