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 getPicName() {
    SimpleDateFormat fat = new SimpleDateFormat("yyyyMMdd_hhmmss");
    return fat.format(new Date()) + ".jpg";
}

From source file:Main.java

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

From source file:Main.java

public static String getFirstDayOfLastMonth() {
    Calendar c = Calendar.getInstance();
    int month = c.get(Calendar.MONTH);
    c.set(Calendar.MONTH, month - 1);
    c.set(Calendar.DAY_OF_MONTH, c.getActualMinimum(Calendar.DAY_OF_MONTH));
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    return df.format(c.getTime());
}

From source file:Main.java

/**
 * "1984/10/18".//from  w ww.ja v  a2 s  . c  om
 *
 * @param date
 * @return
 */
public static String slashedDate(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
    return sdf.format(date);
}

From source file:Main.java

public static String DateToString(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String str = sdf.format(date);
    return str;//from w w w  .  jav a2  s  .  co m
}

From source file:Main.java

public static String nowTime() {
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat(TIME_FORMAT_NOW);
    return sdf.format(cal.getTime());
}

From source file:Main.java

public static String getWeek(Date date) {

    SimpleDateFormat sdf = new SimpleDateFormat("EEEE");
    String week = sdf.format(date);
    return week;//w ww  . j a va2s . c o  m

}

From source file:Main.java

public static String getTimeNow() {
    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
    String time = sdf.format(new Date());
    return time;/*from  w  w w.  j  av a 2s  .c o m*/
}

From source file:Main.java

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

From source file:Main.java

public static String getDate() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String date = sdf.format(new java.util.Date());
    return date;//from www  .j  av a 2 s  . c  om
}