Java Date Format formatDate(Date d)

Here you can find the source of formatDate(Date d)

Description

Convert date to string

License

Open Source License

Declaration

static public String formatDate(Date d) 

Method Source Code

//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;
    }
}

Related

  1. formatDate(Date d)
  2. formatDate(Date d)
  3. formatDate(Date d)
  4. formatDate(Date d)
  5. formatDate(Date d)
  6. formatDate(Date d, int type)
  7. formatDate(Date date)
  8. formatDate(Date date)
  9. formatDate(Date date)