Java Date to String Date2StringSec(Date date)

Here you can find the source of Date2StringSec(Date date)

Description

Date String Sec

License

Apache License

Declaration

public static String Date2StringSec(Date date) 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.*;

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

    public static String Date2StringSec(Date date) {
        SimpleDateFormat formatter = new SimpleDateFormat(DefaultLongFormat);
        return formatter.format(date);
    }//ww  w . j  a v  a 2s . c om

    public static String Date2StringSec(Integer seconds) {
        return Date2StringSec(fromUnixTime(seconds));
    }

    public static Date fromUnixTime(Integer seconds) {
        return new Date(seconds * 1000L);
    }

    public static Date fromUnixTime(Long millis) {
        return new Date(millis);
    }
}

Related

  1. date2String(String pattern, Date date)
  2. date2String2(Date date)
  3. date2StringISO(Date date)
  4. date2StringMD(Date date)
  5. date2StringPattern(Date value, String pattern)
  6. datetime(Date date)
  7. dateTime2String(Date dateTime, DateFormat dateFormat)
  8. dateTimeISO(final java.util.Date date)
  9. dateTimeToZero(Date date)