SimpleDateFormat() - How to Set a Pattern to SimpleDateFormat

public SimpleDateFormat (String pattern) was added in API level 1
Constructs a new SimpleDateFormat using the specified non-localized pattern and the DateFormatSymbols andCalendar for the user's default locale. See "Be wary of the default locale".
Parameters: pattern - the pattern.

1. Declare a SimpleDateFormat variable

2. Add the below line in the onCreate method. This will create the format of a 4-digit year, number month and the number day of the month.

try { 
    mySimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
} catch (NullPointerException e) {
    e.printStackTrace();

} catch (IllegalArgumentException e) {
    e.printStackTrace();
}

3. Compile and run!

4. Other symbols you could use for the format are:

SymbolMeaningKindExample
Dday in year(Number)189
Eday of week(Text)E/EE/EEE:Tue, EEEE:Tuesday, EEEEE:T
Fday of week in month(Number)(2nd Wed in July)
Gera designator(Text)AD
Hhour in day (0-23)(Number)0
Khour in am/pm (0-11)(Number)0
Lstand-alone month(Text)L:1 LL:01 LLL:Jan LLLL:January LLLLL:J
Mmonth in year(Text)M:1 MM:01 MMM:Jan MMMM:January MMMMM:J
Sfractional seconds(Number)978
Wweek in month(Number)2
Ztime zone (RFC 822)(Time Zone)Z/ZZ/ZZZ:-0800 ZZZZ:GMT-08:00 ZZZZZ:-08:00
aam/pm marker(Text)PM
cstand-alone day of week(Text)c/cc/ccc:Tue, cccc:Tuesday, ccccc:T
dday in month(Number)10
hhour in am/pm (1-12)(Number)12
khour in day (1-24)(Number)24
mminute in hour(Number)30
ssecond in minute(Number)55
wweek in year(Number)27
yyear(Number)yy:10 y/yyy/yyyy:2010
ztime zone(Time Zone)z/zz/zzz:PST zzzz:Pacific Standard Time
'escape for text(Delimiter)'Date=':Date=
''single quote(Literal)'o''clock':o'clock

Resources:
http://developer.android.com/reference/java/text/SimpleDateFormat.html#SimpleDateFormat(java.lang.String)