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 getDate() {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
    return dateFormat.format(new Date(System.currentTimeMillis()));
}

From source file:Main.java

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

From source file:Main.java

public static String getToday() {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
    return dateFormat.format(new Date());
}

From source file:Main.java

public static String millisToStringDate(long millis, String pattern) {
    SimpleDateFormat format = new SimpleDateFormat(pattern);
    return format.format(new Date(millis));

}

From source file:Main.java

static String getDateString(String format) {
    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
    return sdf.format(new Date());
}

From source file:Main.java

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

From source file:Main.java

public static String getCurrentTime() {
    SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss.SSS");
    return sdf.format(new Date());
}

From source file:Main.java

@SuppressLint("SimpleDateFormat")
public static String getYMD(long timestamp) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    return sdf.format(new Date(timestamp));
}

From source file:Main.java

public static String GetPostCommentTime(long milliseconds) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(milliseconds);/*from w ww.jav  a 2  s  .  c om*/
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd HH:mm");
    return sdf.format(cal.getTime());
}

From source file:Main.java

public static String getTime(long time) {
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return df.format(time * 1000l);
}