1. Date Style
Before Conversion |
After conversion |
26/Jun/2014: 09: 02: 19 + 0800 |
09:02:19 |
DD/Mmm/yyyy: hh: mm: SS Z |
Yyyy-mm-dd hh: mm: SS |
2. Conversion code
ImportJava. Text. parseexception;
ImportJava. Text. simpledateformat;
ImportJava. util. date;
ImportJava. util. locale;
Public ClassTime {
Public Static VoidMain (string [] ARGs ){
//TodoAuto-generated method stub
String STR = "26/Jun/2014: 09: 02: 19 + 0800 ";
Simpledateformat sdf1 =NewSimpledateformat ("DD/Mmm/yyyy: hh: mm: ss z", locale.Us);
Simpledateformat sdf2 =NewSimpledateformat ("yyyy-mm-dd hh: mm: SS ");
Try{
Date = (date) sdf1.parse (STR );
STR = sdf2.format (date );
System.Out. Println (STR );
}Catch(Parseexception e ){
//TodoAuto-generated Catch Block
E. printstacktrace ();
}
}
}
3. Date Mode
Date |
Letter |
Example |
Year |
Yyyy |
E. g 2009 |
Month |
Mmmm |
E. g October |
Mmm |
E. g Oct |
Mm |
E. g 10 |
Day |
Dd |
E. g 15 |
Day of the week |
Dddd |
E. g Tuesday |
Hours |
HH |
E. g 14 |
Minutes |
Mm |
E. g 30 |
Seconds |
SS |
E. g 59 |