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 formatDate(Date aDate) {
    SimpleDateFormat fmt = new SimpleDateFormat(DATE_FORMAT);
    return fmt.format(aDate);
}

From source file:Main.java

public static String GetFormatDateYMStrByMillseconds(long milliseconds) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(milliseconds);//from ww w.  ja v a  2  s .  c om
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
    return sdf.format(cal.getTime());
}

From source file:Main.java

public static String getFormattedDate(long timestamp) {
    Date date = new Date();
    date.setTime(timestamp);/*from w w w  .  j  a v  a  2 s.  c  o  m*/
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy");
    return sdf.format(date);
}

From source file:Main.java

public static String GetCurrentTime() {
    Date date = new Date();
    SimpleDateFormat format = new SimpleDateFormat("HH:mm");
    return format.format(date);
}

From source file:Main.java

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

From source file:Main.java

public static String getSpritTime(Date date) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy/M/d");
    return format.format(date);
}

From source file:Main.java

public static String dateFormat(Date date, String format) {

    if (format == null || "".equals(format))
        format = YYYY_MM_dd;/*www .  j a  va 2 s  . com*/
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    return sdf.format(date);
}

From source file:Main.java

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

From source file:Main.java

public static String num_format(long time, String type) {
    SimpleDateFormat sdf = new SimpleDateFormat(type);
    String date = sdf.format(new Date(time));
    return date;//  w  w  w . jav a 2s.com
}

From source file:Main.java

public static String getDate(long date) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yy");
    return dateFormat.format(date);
}