Java String to Date toDateString(long ms)

Here you can find the source of toDateString(long ms)

Description

to Date String

License

Apache License

Declaration

public static String toDateString(long ms) 

Method Source Code


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

import java.text.DateFormat;

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

public class Main {
    public static String toDateString(long ms) {
        return format(ms, "yyyy-MM-dd");
    }//from  w w  w.  ja v  a2  s  .  c om

    public static String toDateString(Date date) {
        return toDateString(date.getTime());
    }

    public static String format(long ms, String pattern) {
        DateFormat df = new SimpleDateFormat(pattern);
        return df.format(new Date(ms));
    }
}

Related

  1. toDateString(java.util.Date date)
  2. toDateString(java.util.Date date)
  3. toDateString(java.util.Date date, String format)
  4. toDateString(java.util.Date date, String spe)
  5. toDateString(long lval)
  6. toDateString(String fmt, Date date)
  7. toDateStyleBoth(String dateStr)
  8. toDatetime(String sDate)
  9. toDateTimeFormat(String input, String inputfmt, String outputfmt)