Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 0.88 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Android SimpleDateFormat, how to use it?
  2. String _Date = "2010-09-29 08:45:22"
  3.     SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
  4.  
  5.         try {
  6.             Date date = fmt.parse(_Date);
  7.             return fmt.format(date);
  8.         }
  9.         catch(ParseException pe) {
  10.  
  11.             return "Date";    
  12.         }
  13. }
  14.        
  15. SimpleDateFormat("dd-MM-yyyy");
  16.        
  17. SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
  18. Date date = fmt.parse(dateString);
  19.  
  20. SimpleDateFormat fmtOut = new SimpleDateFormat("dd-MM-yyyy");
  21. return fmtOut.format(date);
  22.        
  23. String _Date = "2010-09-29 08:45:22"
  24. SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
  25. SimpleDateFormat fmt2 = new SimpleDateFormat("dd-MM-yyyy");
  26.     try {
  27.         Date date = fmt.parse(_Date);
  28.         return fmt2.format(date);
  29.     }
  30.     catch(ParseException pe) {
  31.  
  32.         return "Date";    
  33.     }
  34.        
  35. DateFormat.getDateFormat