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 getHumanDate(long mils) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return sdf.format(new Date(mils));
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static String getSignTimestamp() {
    long time = new Date().getTime();
    SimpleDateFormat format = new SimpleDateFormat("yyyyMMHHmmssdd");
    return format.format(new Date(time));
}

From source file:Main.java

@SuppressLint("SimpleDateFormat")
public static String getTime(long date) {
    SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm:ss");
    return format.format(date);
}

From source file:Main.java

public static String timeFormat(long timestamp) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    return format.format(new Date(timestamp));
}

From source file:Main.java

public static String ToString(Calendar date) {
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy", Locale.US);
    return sdf.format(date.getTime());
}

From source file:Main.java

public static String transferTime(String timestamp) {
    String newValue = "";
    long ts = Long.valueOf(timestamp);
    SimpleDateFormat df = new SimpleDateFormat("MMM d\nHH:mm");
    newValue = df.format(ts);
    return newValue;
}

From source file:Main.java

public static String getCurrentDate() {
    Calendar calander = Calendar.getInstance();
    SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
    String date = df.format(calander.getTime());
    return date;//from  w  w w.j  av  a2  s  .c  om
}

From source file:Main.java

/**
 * getCurrentDate: return current time with year-month-day format
 * @return//from   w w w  .  j  a va2s . c  om
 */
public static String getCurrentDate() {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    return dateFormat.format(new java.util.Date());
}