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 format(long time, String pattern) {
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    return sdf.format(new Date(time));
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static String getDateWeek(long time) {
    SimpleDateFormat sdf = new SimpleDateFormat("E");
    String dt = sdf.format(time);
    return dt;//from  w  w  w  .  ja  v  a2s .c o m
}

From source file:Main.java

public static String getRealTime(int unixTime) {
    Date now = new Date((unixTime) * 1000L);
    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
    return sdf.format(now);
}

From source file:Main.java

public static boolean areEqualMonth(Calendar c1, Calendar c2) {
    SimpleDateFormat sdf = new SimpleDateFormat("MM-yyyy");
    return (sdf.format(c1.getTime()).equals(sdf.format(c2.getTime())));
}

From source file:Main.java

public static String getToday() {
    SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
    return df.format(Calendar.getInstance().getTime());
}

From source file:Main.java

public static String currentTime(String format) {
    SimpleDateFormat df = new SimpleDateFormat(format);
    return df.format(new Date());
}

From source file:Main.java

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