Here you can find the source of formatDate(Date d)
static public String formatDate(Date d)
//package com.java2s; /*/*from ww w .ja va2s. c om*/ * IRIS -- Intelligent Roadway Information System * Copyright (C) 2009-2014 Minnesota Department of Transportation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ import java.text.SimpleDateFormat; import java.util.Date; public class Main { /** Convert date to string */ static public String formatDate(Date d) { if (d != null) { SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd"); return f.format(d); } else return null; } }