Created
March 14, 2016 14:50
-
-
Save victorvaz/e959fc845a9e623e250a 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
package datanojava; | |
import java.text.DateFormat; | |
import java.util.Date; | |
public class FormatarDataFormat { | |
public static void main (String[] args) { | |
Date data = new Date(); | |
System.out.println(data); // Mon Mar 14 11:48:49 BRT 2016 | |
DateFormat dfs = DateFormat.getDateInstance(DateFormat.SHORT); | |
System.out.println(dfs.format(data)); // 14/03/16 | |
DateFormat dfm = DateFormat.getDateInstance(DateFormat.MEDIUM); | |
System.out.println(dfm.format(data)); // 14/03/2016 | |
DateFormat dfl = DateFormat.getDateInstance(DateFormat.LONG); | |
System.out.println(dfl.format(data)); // 14 de Março de 2016 | |
DateFormat dff = DateFormat.getDateInstance(DateFormat.FULL); | |
System.out.println(dff.format(data)); // Segunda-feira, 14 de Março de 2016 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment