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 getDateTimeByMillisecond(String str, String type) {
    Date date = new Date(Long.valueOf(str));
    SimpleDateFormat format = new SimpleDateFormat(type);
    String time = format.format(date);
    return time;/*from  www .  j  a  va 2  s. c o  m*/
}

From source file:Main.java

public static String toStringDate(Date date) {
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return df.format(date);
}

From source file:Main.java

public static String formatDate(Date date, String format) {
    String dateString = "";
    if (date != null) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        return sdf.format(date);
    }//from   w  w  w  . ja  v  a  2  s.  c o m
    return dateString;
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static String getTodaysDate() {
    SimpleDateFormat formater = new SimpleDateFormat(sqlDateFormat);
    return formater.format(new Date());
}

From source file:Main.java

public static String dateToStringVistaInici(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM");
    String sDate = sdf.format(date);
    return sDate;
}

From source file:Main.java

public static String getSimpleTime(long time) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-M-d");
    return format.format(new Date(time));
}

From source file:Main.java

public static String getNowTime() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return sdf.format(new Date().getTime());
}

From source file:Main.java

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