Java Long Number to Date formatDate(long date)

Here you can find the source of formatDate(long date)

Description

format Date

License

Apache License

Declaration

public static String formatDate(long date) 

Method Source Code

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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

    public static String formatDate(Date date, String format) {
        SimpleDateFormat formatter = new SimpleDateFormat(format);
        System.out.println(formatter.format(date).toString());
        return formatter.format(date).toString();

    }/*from   w w w. ja v  a  2s .c  o  m*/

    public static String formatDate(String date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        SimpleDateFormat sdf2 = new SimpleDateFormat(format);
        String sss = null;
        try {
            sss = sdf2.format(sdf.parse(date));
            //System.out.println(sss);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return sss;
    }

    public static String formatDate(long date) {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println(formatter.format(date));
        return formatter.format(date);
    }
}

Related

  1. formatDate(long d)
  2. formatDate(long date)
  3. formatDate(Long date)
  4. formatDate(long date)
  5. formatDate(long date)
  6. formatDate(long date)
  7. formatDate(long date)
  8. formatDate(long date)
  9. formatDate(Long date, String fmt)