Java Date Create toDate(int flag, Date... date)

Here you can find the source of toDate(int flag, Date... date)

Description

to Date

License

Open Source License

Declaration


public static String toDate(int flag, Date... date) 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final String FORMAT_0 = "yyyy-MM-dd HH:mm:ss";
    private static final String FORMAT_1 = "yyyy-MM-dd";
    private static final String FORMAT_2 = "HH:mm:ss";

    public static String toDate(int flag, Date... date) {

        SimpleDateFormat simple = null;
        if (flag == 0)
            simple = new SimpleDateFormat(FORMAT_0);
        else if (flag == 1)
            simple = new SimpleDateFormat(FORMAT_1);
        else/*from w w  w.j  a  v  a  2 s . c  o m*/
            simple = new SimpleDateFormat(FORMAT_2);
        if (date.length > 0) {
            return simple.format(date[0]);
        }
        return simple.format(new Date());

    }
}

Related

  1. toDate(Calendar date)
  2. toDate(Date d)
  3. toDate(final Calendar calendar)
  4. toDate(final Date date)
  5. toDate(int date)
  6. toDate(long lastModified)
  7. toDate(long segundos)
  8. toDate(long time)
  9. toDate(long time)