Example usage for java.text DateFormat format

List of usage examples for java.text DateFormat format

Introduction

In this page you can find the example usage for java.text DateFormat 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 longToDateTime(long timestamp) {
    Date date = new Date(timestamp * 1000);
    DateFormat formatter = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
    return formatter.format(date);
}

From source file:Main.java

public static String dateFormatShort(Date date) {
    DateFormat dateFormat1 = DateFormat.getDateInstance(DateFormat.SHORT);
    return dateFormat1.format(date);
}

From source file:Main.java

public static String getCurrentMonth(long time) {
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM", Locale.CHINA);
    return dateFormat.format(time);
}

From source file:Main.java

public static String mediumFormat(Date date) {
    DateFormat dateFormat1 = DateFormat.getDateInstance(DateFormat.MEDIUM);
    return dateFormat1.format(date);
}

From source file:Main.java

public static String formatDate(Date date) {
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm a");
    return dateFormat.format(date);
}

From source file:Main.java

/**
 * yyyyMMdd//from  www  .j a  v a2  s .c  o  m
 * 
 * @param date
 * @return
 */
public static String dateToIntString(Date date) {
    DateFormat dateformat = new SimpleDateFormat("yyyyMMdd");
    return dateformat.format(date);
}

From source file:Main.java

public static String getTime() {
    Date date = new Date();
    DateFormat format = new SimpleDateFormat("HH:mm", Locale.getDefault());
    return format.format(date);
}

From source file:Main.java

public static String format(Date paramDate, DateFormat paramDateFormat) {
    if (paramDate != null)
        return paramDateFormat.format(paramDate);
    return null;/*from w  ww .  ja  v a2 s.  co m*/
}

From source file:Main.java

public static String getCurrentDate(long time) {
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
    return dateFormat.format(time);
}

From source file:Main.java

private static String getInstantTimestamp() {
    DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
    String dateFormatted = formatter.format(new Date());
    return "[" + dateFormatted + "]" + " ";
}