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 timeStampToStr1(long timeStamp) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    String date = sdf.format(timeStamp * 1000);
    return date;// w w w.j  av a2s.  c  o m
}

From source file:Main.java

public static String convertDate(Date date) {

    SimpleDateFormat format = new SimpleDateFormat(DATE_TIME_FORMAT);

    return format.format(date);

}

From source file:Main.java

public static String now() {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return dateFormat.format(Calendar.getInstance().getTime());
}

From source file:Main.java

public static String createFileName(String fileType) {
    String fileName = "";
    Date date = new Date(System.currentTimeMillis());
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
    fileName = sdf.format(date) + fileType;
    return fileName;
}

From source file:Main.java

@SuppressLint("SimpleDateFormat")
public static String getNowTime() {
    Date date = new Date(System.currentTimeMillis());
    SimpleDateFormat dateFormat = new SimpleDateFormat("MMddHHmmssSS");
    return dateFormat.format(date);
}

From source file:Main.java

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

From source file:Main.java

public static String get_date(String args) {

    // long nowTime=System.currentTimeMillis();
    long retime = Integer.valueOf(args).intValue();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String date = sdf.format(new Date(retime * 1000));
    return date;/*from  ww  w.j a  v  a  2  s.co m*/
    // System.out.print(date);
}

From source file:Main.java

public static String GetSysTimeshort() {
    SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    String date = sDateFormat.format(new java.util.Date());
    return date;//www  .  j ava 2 s  .  c o  m
}

From source file:Main.java

public static String getFormatterTime(long time) {
    Date d = new Date(time);
    SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
    String data = formatter.format(d);
    return data;/*  ww  w .j  a  v a  2s . com*/
}

From source file:Main.java

public static String day(Date now) {
    SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
    String strDate = sdfDate.format(now);
    return strDate;
}