Mega Code Archive

 
Categories / Android / Date Type
 

Format a date into a format suitable for SQLite

/**    * Format a date into a format suitable for SQLite    *     * @param date The date to format    * @return The formatted date, or null if it could not be formatted.    */   public static String dateToSqliteDateString(Date date) {     // The format is the same as CURRENT_TIMESTAMP: "YYYY-MM-DD HH:MM:SS"     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");     if (date != null) {       return sdf.format(date);     }     return null;   }