Example usage for java.text SimpleDateFormat format

List of usage examples for java.text SimpleDateFormat format

Introduction

In this page you can find the example usage for java.text SimpleDateFormat format.

Prototype

public final String format(Date date) 

Source Link

Document

Formats a Date into a date-time string.

Usage

From source file:Main.java

public static String getSpecialFormatTime(String format) {
    SimpleDateFormat tm = new SimpleDateFormat(format);
    return tm.format(new Date());
}

From source file:Main.java

public static String getDate(String format) throws Exception {
    SimpleDateFormat fm = new SimpleDateFormat(format);
    return fm.format(new Date());
}

From source file:Main.java

public static String getCurrentDate(String format) {
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    return sdf.format(new Date()).toString();
}

From source file:Main.java

public static String formatHHmm(long ms) {
    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
    return sdf.format(ms);
}

From source file:Main.java

public static String getTimeString(Date date) {
    SimpleDateFormat df = new SimpleDateFormat("h:mma");
    return df.format(date);
}

From source file:Main.java

public static String calendar2strDate(Calendar calendar, String pattern) {
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    return sdf.format(calendar.getTime());
}

From source file:Main.java

public static String format(Date date, String pattern) {
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    return sdf.format(date);
}

From source file:Main.java

public static String getDataTime(String format) {
    SimpleDateFormat df = new SimpleDateFormat(format);
    return df.format(new Date());
}

From source file:Main.java

public static String convertTime(long time) {
    String format = "M-d k:mm";
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    return sdf.format(time);
}

From source file:Main.java

public static String niceDate(Long date) {
    SimpleDateFormat ft = new SimpleDateFormat("E d MMM");
    return ft.format(new Date(date));
}