package rhymes.dateformat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateFormatExample {
/**
* @param args
*/
public static void main(String[] args) {
String format[] = { "yyyy.MM.dd G 'at' HH:mm:ss z",
"MM/dd/yyyy hh:mm:ss a z", "MM/dd/yyyy kk:mm:ss z",
"EEE, MMM d, ''yy", "h:mm a", "hh 'o''clock' a, zzzz",
"K:mm a, z", "yyyyy.MMMMM.dd GGG hh:mm aaa",
"EEE, d MMM yyyy HH:mm:ss Z", "yyMMddHHmmssZ" };
Date today = new Date();
for (int i = 0; i lt; format.length; i++) {
SimpleDateFormat formatter = new SimpleDateFormat(format[i]);
System.out.println("\"" + format[i] + "\" : "
+ formatter.format(today));
}
}
}
"yyyy.MM.dd G 'at' HH:mm:ss z" | 2008.06.17 AD at 17:45:18 IST |
"MM/dd/yyyy hh:mm:ss a z" | 06/17/2008 05:45:18 PM IST |
"MM/dd/yyyy kk:mm:ss z" | 06/17/2008 17:45:18 IST |
"EEE, MMM d, ''yy" | Tue, Jun 17, '08 |
"h:mm a" | 5:45 PM |
"hh 'o''clock' a, zzzz" | 05 o'clock PM, India Standard Time |
"K:mm a, z" | 5:45 PM, IST |
"yyyyy.MMMMM.dd GGG hh:mm aaa" | 02008.June.17 AD 05:45 PM |
"EEE, d MMM yyyy HH:mm:ss Z" | Tue, 17 Jun 2008 17:45:18 +0530 |
"yyMMddHHmmssZ" | 080617174518+0530 |
1 comment:
Perfect..
Thanx,...
Post a Comment