Java Time Format getStringFromTime(Date time, String format)

Here you can find the source of getStringFromTime(Date time, String format)

Description

get String From Time

License

Open Source License

Declaration

public static String getStringFromTime(Date time, String format) 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public final static String FORMAT_DATE_TIME = "yyyy-MM-dd hh:mm";
    private static SimpleDateFormat sdf = new SimpleDateFormat();

    public static String getStringFromTime(Date time, String format) {
        if (format == null || format.trim().equals("")) {
            sdf.applyPattern(FORMAT_DATE_TIME);
        } else {/*from  w w w . jav  a  2 s . co m*/
            sdf.applyPattern(format);
        }
        return sdf.format(time);
    }
}

Related

  1. getShowTime(Date date, String format)
  2. getStartTimeFormatter()
  3. getStrDateByFormat(Date time, String format)
  4. getStrDateTime()
  5. getStringFormatFromDateTime(long pDateTime, String format)
  6. getSysDateTimeForFileName()
  7. getSysTimeYMDHMS2()
  8. getTime(@Nonnull String format, @Nonnull String date, @Nonnull String tz)
  9. getTime(Date dt, String format)