Java Date to String date2String(java.util.Date date, String pattern)

Here you can find the source of date2String(java.util.Date date, String pattern)

Description

date String

License

Open Source License

Declaration

public static String date2String(java.util.Date date, String pattern) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

public class Main {
    public static final String PATTERN_STANDARD = "yyyy-MM-dd HH:mm:ss";

    public static String date2String(java.util.Date date, String pattern) {
        if (date == null) {
            throw new java.lang.IllegalArgumentException("timestamp null illegal");
        }//  w ww .  ja  va  2s .c o m
        if (pattern == null || pattern.equals("")) {
            pattern = PATTERN_STANDARD;
            ;
        }
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(date);
    }
}

Related

  1. Date2String(Date date, String formatPattern)
  2. date2String(Date date, String pattern)
  3. date2String(Date source, String formatString)
  4. date2String(Date value)
  5. date2String(java.util.Date date, String format)
  6. date2String(String formater, Date aDate)
  7. date2String(String pattern, Date date)
  8. date2String2(Date date)
  9. date2StringISO(Date date)