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 getDate(long time) {
    SimpleDateFormat format = new SimpleDateFormat("y/M/d");
    return format.format(new Date(time));
}

From source file:Main.java

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

From source file:Main.java

public static String getDate(Calendar c) {
    System.out.println("c: " + c);
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    return df.format(c.getTime());
}

From source file:Main.java

@Deprecated
public static String switchTime(long time, String format) {
    Date date = new Date(time);
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    return sdf.format(date);
}

From source file:Main.java

public static String getDateTime() {
    String paramFormat = "yyyy-MM-dd";
    SimpleDateFormat sdf = new SimpleDateFormat(paramFormat);
    return sdf.format(System.currentTimeMillis()).toString();
}

From source file:Main.java

public static String getDataTimeALL(long time) {
    String paramFormat = "yyyy-MM-dd HH:mm";
    SimpleDateFormat sdf = new SimpleDateFormat(paramFormat);
    return sdf.format(time).toString();
}

From source file:Main.java

public static String getStringFromDate(Date time, String formatString) {
    SimpleDateFormat sdf = new SimpleDateFormat(formatString);
    return sdf.format(time);
}

From source file:Main.java

public static String date2String(long time, String format) {
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    String s = sdf.format(time);
    return s;/*from  www  .  j  a  v a 2s.com*/
}

From source file:Main.java

public static String getDateHM(long time) {
    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
    String dt = sdf.format(time);
    return dt;//  w  w w  . j av a 2  s.c  o  m
}

From source file:Main.java

public static String currentDate() {
    Calendar c = Calendar.getInstance();
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    return df.format(c.getTime());
}