Java Hour Format formatDateTime(Date date)

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

Description

format Date Time

License

Open Source License

Declaration

public static String formatDateTime(Date date) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.TimeZone;

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

    public static String formatDateTime(Date date) {
        if (date == null)
            return null;
        SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATETIME);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
        return sdf.format(date);
    }//from   w ww.j a va2s.c  om

    public static String formatDateTime(Date date, String style) {
        if (date == null)
            return null;
        SimpleDateFormat sdf = new SimpleDateFormat(style);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
        return sdf.format(date);
    }
}

Related

  1. formatDateTime(Date date)
  2. formatDateTime(Date date)
  3. formatDateTime(Date date)
  4. formatDateTime(Date date)
  5. formatDateTime(Date date)
  6. formatDateTime(Date date)
  7. formatDateTime(Date date)
  8. formatDateTime(Date date)
  9. formatDateTime(Date dateTime)