Java tutorial
//package com.java2s; /** * Transform date or time to various formats * * @copyright Copyright (C) 2012 - 2013 Information Technology Institute ITI-CERTH. All rights reserved. * @license GNU Affero General Public License version 3 or later; see LICENSE.txt * @author Dimitrios Ververidis for the Multimedia Group (http://mklab.iti.gr). * */ import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** * Convert date object to yyyy-MM-dd HH:mm:ss string * * @param date date object * @return */ public static String DateToString(Date date) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); StringBuilder sb = new StringBuilder(dateFormat.format(date)); return sb.toString(); } }