Here you can find the source of toDateString(String fmt, Date date)
public static String toDateString(String fmt, Date date)
//package com.java2s; /**//from www .j a v a 2 s . com * KTH Developed by Java * * @Copyright 2011 by Service Platform Development Team, KTH, Inc. All rights reserved. * * This software is the confidential and proprietary information of KTH, Inc. * You shall not disclose such Confidential Information and shall use it only * in accordance with the terms of the license agreement you entered into with KTH. */ import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String toDateString() { return toDateString("yyyy-MM-dd HH:mm:ss", new Date()); } public static String toDateString(String fmt, Date date) { return new SimpleDateFormat(fmt).format(date); } }