Example usage for java.text SimpleDateFormat SimpleDateFormat

List of usage examples for java.text SimpleDateFormat SimpleDateFormat

Introduction

In this page you can find the example usage for java.text SimpleDateFormat SimpleDateFormat.

Prototype

public SimpleDateFormat(String pattern) 

Source Link

Document

Constructs a SimpleDateFormat using the given pattern and the default date format symbols for the default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:Main.java

public static String getDateAndTimeFormatString(long times) {
    return new SimpleDateFormat("MM-dd HH:mm").format(new Date(times));
}

From source file:Main.java

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

From source file:Main.java

public static String getYear(Long time) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy");
    Date date = new Date(time);
    return dateFormat.format(date);
}

From source file:Main.java

public static String getHourAndMin(long time) {
    SimpleDateFormat format = new SimpleDateFormat("HH:mm");
    return format.format(new Date(time));
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static String longToString(Long longTime, String pattern) {
    SimpleDateFormat df = new SimpleDateFormat(pattern);
    try {/* w  w w.j  a v a2s.  c o m*/
        return df.format(longTime);
    } catch (Exception e) {
        return "";
    }
}

From source file:Main.java

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

From source file:Main.java

public static String getSpritTime(Date date) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy/M/d");
    return format.format(date);
}

From source file:Main.java

public static String timestamp2Date(String time) {
    SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return sf.format(new Date(Long.parseLong(time) * 1000));
}