Java Date Format dateTimeToStr(Date date, String format)

Here you can find the source of dateTimeToStr(Date date, String format)

Description

date Time To Str

License

Open Source License

Declaration

public static String dateTimeToStr(Date date, String format) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.TimeZone;

public class Main {

    public static String dateTimeToStr(Date date, String format) {
        String _timeZone = System.getProperty("user.timezone");
        TimeZone timeZone = null;
        if (_timeZone == null || "".equals(_timeZone)
                || "UTC".equals(_timeZone)) {
            timeZone = TimeZone.getDefault();
        } else {/*from   w w w.  ja v  a  2s .com*/
            timeZone = TimeZone.getTimeZone("Asia/Shanghai");
        }
        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
        dateFormat.setTimeZone(timeZone);
        return dateFormat.format(date);
    }
}

Related

  1. dateTime2StringFs(Date date)
  2. dateTimeFormat(Date dateTime)
  3. DateTimeFormat(final Date date)
  4. dateTimeFormatterDate(Date date)
  5. dateTimeToMillis(String dateTime, String format)
  6. dateTimeToZuluFormat(DateTime dateTime)
  7. formatD(Date date)
  8. formatDashedDateDDMMYYYY(Date date)
  9. formatDate(ArrayList list)