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 normalDateFormat(Date date) {
    SimpleDateFormat format = new SimpleDateFormat("MMMM dd, yyyy");
    return format.format(date);
}

From source file:Main.java

public static String getUniqueFileName() {
    // use the create time as the file name
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
    return sdf.format(new Date());
}

From source file:Main.java

public static String getChangeTimeFormat(Date date) {
    String str = null;/* w w w . ja v a2s.c  om*/
    if (date != null && !"".equals(date)) {
        SimpleDateFormat sd = new SimpleDateFormat("HH:mm");
        str = sd.format(date);
    }
    return str;
}

From source file:Main.java

@SuppressLint("SimpleDateFormat")
public static String getPhoneCurrentTime() {
    SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
    return date.format(Calendar.getInstance().getTime());
}

From source file:Main.java

public static String getTomorrow() {
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, 1);/* w  ww . ja  va2 s . com*/
    Date date = cal.getTime();
    SimpleDateFormat sf = new SimpleDateFormat(DATE_FORMAT);
    return sf.format(date);
}

From source file:Main.java

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

From source file:Main.java

public static String getDateStr(long milliseconds, String format) {
    SimpleDateFormat df = new SimpleDateFormat(format);
    return df.format(new Date(milliseconds));
}

From source file:Main.java

public static String getStringTime(long timestamp, String format) {
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    String result = sdf.format(new Date(timestamp));
    return result;
}

From source file:Main.java

public static String getDateFromSeconds(long secs) {
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(secs * 1000L);//from   www  .  j  a v a2  s. c o m
    SimpleDateFormat format1 = new SimpleDateFormat("dd.MM.yyyy");
    return format1.format(c.getTime());
}

From source file:Main.java

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