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 getDataToString(Date date) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return format.format(date);
}

From source file:Main.java

public static String horaParaString(java.sql.Timestamp data) {

    try {// w  ww  .  j  ava2s. com
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        return sdf.format(data);
    } catch (Exception e) {
        Log.e("afaLog", "Houve um problema ao obter uma data (data para string)");
        return null;
    }
}

From source file:Main.java

public static String getTodaysDateTime() {
    SimpleDateFormat formater = new SimpleDateFormat(sqlDateTimeFormat);
    return formater.format(new Date());
}

From source file:Main.java

public static String format(Date date) {
    SimpleDateFormat sdf = new SimpleDateFormat(DATEFORMAT_NORMAL);
    return sdf.format(date);
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static String getBackupFileName() {
    Calendar c = Calendar.getInstance();
    SimpleDateFormat format1 = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
    return format1.format(c.getTime()) + ".txt";
}

From source file:Main.java

public static String getDayOfWeekString(int day) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.DAY_OF_WEEK, day);
    SimpleDateFormat format = new SimpleDateFormat("EEE", Locale.US);
    return format.format(calendar.getTime());
}

From source file:Main.java

public static String getNowTimeString() {
    SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd_hhmmss");
    return sDateFormat.format(new java.util.Date());
}

From source file:Main.java

public static String getFileName() {
    Date date = new Date(System.currentTimeMillis());
    SimpleDateFormat sdf = new SimpleDateFormat("'img'_yyyyMMdd_HHmmss");
    return sdf.format(date) + ".jpg";
}