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 getChineseTime(long time) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd");
    return format.format(new Date(time));
}

From source file:Main.java

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

From source file:Main.java

public static String calendarToString(Calendar cal, String format) {
    SimpleDateFormat dateFormat = new SimpleDateFormat(format);

    return dateFormat.format(cal.getTime());
}

From source file:Main.java

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

From source file:Main.java

static String getDate() {

    Calendar calendar = Calendar.getInstance();
    SimpleDateFormat df = new SimpleDateFormat("dd MMMM yyyy");
    return df.format(calendar.getTime());
}

From source file:Main.java

public static String getFormattedDate(Calendar cal) {
    SimpleDateFormat sdf = new SimpleDateFormat("d MMMM yyyy, h a");
    return sdf.format(cal.getTime());
}

From source file:Main.java

public static String getStringByDate(Date date, String pattern) {

    if (date == null)
        return null;
    SimpleDateFormat format = new SimpleDateFormat(pattern);
    return format.format(date);
}

From source file:Main.java

public static String getFragmentDate(int offSet) {
    Date fragmentdate = new Date(System.currentTimeMillis() + (offSet * 86400000));
    SimpleDateFormat mformat = new SimpleDateFormat("yyyy-MM-dd");
    return mformat.format(fragmentdate);
}

From source file:Main.java

public static String getCurrentYear() {
    Date NowDate = new Date();

    SimpleDateFormat formatter = new SimpleDateFormat("yyyy");
    return formatter.format(NowDate);
}

From source file:Main.java

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