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 dateFormatString(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String _date = sdf.format(date);
    return _date;
}

From source file:Main.java

@SuppressLint("SimpleDateFormat")
public static String formatDate() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    return sdf.format(new Date());
}

From source file:Main.java

public static String getCurrentDateTimeString() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return sdf.format(new Date());
}

From source file:Main.java

public static String getDatetime() {
    Calendar calendar = Calendar.getInstance();

    SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_DATETIME);
    return sdf.format(calendar.getTime());
}

From source file:Main.java

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

From source file:Main.java

/**
 * Get String current time./*from   www.  j  a va2 s . c  o m*/
 *
 * @param format use format from FDataUtil. {@link FTimeUtil#FORMAT_1}
 * @return
 */
public static String getCurrentTime(String format) {
    SimpleDateFormat df = new SimpleDateFormat(format);
    return df.format(new Date(System.currentTimeMillis()));
}

From source file:Main.java

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

From source file:Main.java

public static String getMID() {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmms");
    return dateFormat.format(System.currentTimeMillis());
}

From source file:Main.java

public static String formatDate(Calendar calendar) {
    String format = "yyyy-MM-dd HH:mm:ss";
    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
    return sdf.format(calendar.getTime());
}

From source file:Main.java

public static String getNowDateFormat(String format) {
    final Date currentTime = new Date();
    final SimpleDateFormat formatter = new SimpleDateFormat(format);
    return formatter.format(currentTime);
}