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 currentDate() {
    SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd");
    return DATE_FORMAT.format(new Date());
}

From source file:Main.java

public static String formatDate(long timeStamp) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String date = sdf.format(timeStamp * 1000);
    return date;/*  w  ww  .j  a  v a 2s.c  o m*/
}

From source file:Main.java

public static String getPhotoFilename(Date date) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddKms");
    return dateFormat.format(date) + ".jpg";
}

From source file:Main.java

public static String getDateAndTimeSlashString(long timestamp) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm");
    return format.format(new Date(timestamp));
}

From source file:Main.java

public static String ParseDateToString(Date date, String format) {
    SimpleDateFormat dateFormat = new SimpleDateFormat(format);

    return dateFormat.format(date);
}

From source file:Main.java

public static String now() {
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
    return sdf.format(cal.getTime());

}

From source file:Main.java

public static String timestamp2Date(String time) {
    SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return sf.format(new Date(Long.parseLong(time) * 1000));
}

From source file:Main.java

public static String getDateAndTimeDotString(long timestamp) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm");
    return format.format(new Date(timestamp));
}

From source file:Main.java

public static String getReadableDateTime(long time) {
    //todo if it take bad performance or take much more memory,then the android.text.format.DateFormat will be thought.
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_FORMAT);
    return sdf.format(new Date(time));
}

From source file:Main.java

@SuppressLint("SimpleDateFormat")
public static String parseDateToString(Date date, String format) {
    SimpleDateFormat dateFormat = new SimpleDateFormat(format);
    return dateFormat.format(date);
}