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 calendar2TimeString(Calendar calendar) {
    SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm");
    return format.format(calendar.getTime());
}

From source file:Main.java

public static String getCurrentDate() {
    Date dt = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    return sdf.format(dt);
}

From source file:Main.java

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

From source file:Main.java

public static String getDate() {
    SimpleDateFormat sdf = new SimpleDateFormat(" MMM dd yyyy");
    return sdf.format(new Date());
}

From source file:Main.java

/**
 * date format yyyy-MM-dd//from  ww w .  jav a2s. c om
 * */
public static String DateFormate(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    return sdf.format(date);
}

From source file:Main.java

public static String getDateTime(Date date) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    return format.format(date);
}

From source file:Main.java

@SuppressLint("SimpleDateFormat")
public static String getCurrentDate() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
    return sdf.format(new Date());
}

From source file:Main.java

public static String getDateHMS(long time) {
    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
    String dt = sdf.format(time);
    return dt;/*from   www .jav a2s  .  co m*/
}

From source file:Main.java

public static String getDate(Date date) {
    SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm");
    return format.format(date);
}

From source file:Main.java

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