Mega Code Archive

 
Categories / Android / Date Type
 

Get the string of the date using format yyyy-MM-dd HH

import java.text.SimpleDateFormat; import java.util.Date; class Main{   /**    * Get the string of the date using format "yyyy-MM-dd HH:mm:ss"    * @param date    * @return a string formatted from date    */   public static String getDateString(Date date)   {     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");     String time = sdf.format(date);     return time;   } }