Java Date Format dateFormat(Date date, String pattern)

Here you can find the source of dateFormat(Date date, String pattern)

Description

date Format

License

Apache License

Declaration

public static String dateFormat(Date date, String pattern) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static String dateFormat(Date date, String pattern) {
        if (date == null || isNullString(pattern)) {
            return "";
        }//w  w  w .jav  a  2 s. co  m
        SimpleDateFormat format = new SimpleDateFormat(pattern);
        return format.format(date);
    }

    public static boolean isNullString(String target) {
        if (target == null || "".equals(target.trim())) {
            return true;
        }
        return false;
    }
}

Related

  1. dateFormat(Date date)
  2. dateFormat(Date date, String format)
  3. dateFormat(Date date, String format)
  4. dateFormat(Date date, String pattern)
  5. dateFormat(Date date, String pattern)
  6. dateFormat(DateFormat f, Date d)
  7. dateFormat(int grain, TimeZone timeZone)
  8. dateFormat(java.util.Date date, String formatStr)
  9. dateFormat(long time)