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 dateLongFormatString(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat("EEEE dd MMMM yyyy");
    String _date = sdf.format(date);
    return _date;
}

From source file:Main.java

public static String getYear() {
    Date currentTime = new Date();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy");
    String dateString = formatter.format(currentTime);
    return dateString;
}

From source file:Main.java

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

From source file:Main.java

public static String IntToDate(long pTime) {
    Date vD = new Date();
    if (pTime != 0)
        vD.setTime(pTime);/* w ww.ja v  a2 s .  c  o  m*/
    SimpleDateFormat vDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return vDF.format(vD);
    //       return (String) DateFormat.format("yyyy-MM-dd hh:mm:ss", vTime);
}

From source file:Main.java

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

From source file:Main.java

public static String getMMdd(Date date) {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT_MD);
    return simpleDateFormat.format(date);
}

From source file:Main.java

public static String DataToInt(Date dateImg) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
    String strDate = sdf.format(dateImg);
    String[] strs = strDate.split("/");
    int[] ints = { Integer.parseInt(strs[0]), Integer.parseInt(strs[1]), Integer.parseInt(strs[2]) };
    return ints[0] + "-" + ints[1] + "-" + ints[2];
}

From source file:Main.java

public static String convertUnixTime(int time) {
    if (time == 0) {
        return "";
    }/*  w ww.ja v a2s  .  c om*/
    Date date = new Date(time * 1000);
    SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm");
    return format.format(date);
}

From source file:Main.java

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

From source file:Main.java

public static boolean equalsDay(Date a, Date b) {
    SimpleDateFormat yearFormat = new SimpleDateFormat("yyyyMMdd", locale);
    return yearFormat.format(a).equals(yearFormat.format(b));
}