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 getTimeShort() {
    SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
    Date currentTime = new Date();
    String dateString = formatter.format(currentTime);
    return dateString;
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static String getCurrentTimeStr() {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
    Date curDate = new Date(System.currentTimeMillis());
    String str = formatter.format(curDate);
    return str;/*from ww w. ja v  a2 s.c  o  m*/
}

From source file:Main.java

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

From source file:Main.java

public static String getCurrentTimeStamp() {
    SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    Date now = new Date();
    String strDate = sdfDate.format(now);
    return strDate;
}

From source file:Main.java

public static String getCurrentDate() {
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
    Date date = new Date();
    String mCurrentDate = dateFormat.format(date).toString();

    return mCurrentDate;
}

From source file:Main.java

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

From source file:Main.java

public static String getCurrentTime() {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMddHHmmss");
    Date now = new Date();
    return dateFormat.format(now);
}

From source file:Main.java

public static String getDateAs(String format) {
    SimpleDateFormat formatter = new SimpleDateFormat(format);
    return formatter.format(new Date(System.currentTimeMillis()));
}