Java Date to String Date2String(Date date, String DateFormat)

Here you can find the source of Date2String(Date date, String DateFormat)

Description

Date String

License

Open Source License

Declaration

public static String Date2String(Date date, String DateFormat) 

Method Source Code

//package com.java2s;
/**//from w  w w.  ja  va  2 s.c o m
 * B5mDateUtils.java
 *
 * ?  ???????????
 * ?  ????B5mDateUtils
 *
 *   ver     ?????       ????      ??     ??????
 * ????????????????????????????????????
 *   V1.00  '12-05-24  iZENEsoft    wiley.wang       ???
 *
 * Copyright (c) 2009 iZENEsoft Business Software corporation All Rights Reserved.
 * LICENSE INFORMATION
 */

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static String Date2String(Date date) {
        if (null == date) {
            return "";
        }
        return Date2String(date, "yyyy-MM-dd");
    }

    public static String Date2String(Date date, String DateFormat) {
        SimpleDateFormat sdf = new SimpleDateFormat(DateFormat);
        try {
            return sdf.format(date);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

    }
}

Related

  1. date2String(Date date)
  2. date2String(Date date)
  3. date2String(Date date)
  4. date2String(Date date, DateFormat dateFormat)
  5. date2String(Date date, int _iType)
  6. date2string(Date date, String format)
  7. date2String(Date date, String format)
  8. date2String(Date date, String format)
  9. Date2String(Date date, String formatPattern)