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 getPhotoFileName() {
    Date date = new Date(System.currentTimeMillis());
    SimpleDateFormat dateFormat = new SimpleDateFormat("'IMG'_yyyyMMdd_HHmmss");
    return dateFormat.format(date) + ".jpg";
}

From source file:Main.java

public static String getPrettyDate(Calendar c) {
    if (c != null) {
        SimpleDateFormat dateFormatter = new SimpleDateFormat("EEE, MMM d");
        return dateFormatter.format(c.getTime());
    } else {//from www  . j  a  va2  s.  co  m
        return "";
    }
}

From source file:Main.java

static public String getTimeStamp() {
    Date dt = new Date();
    SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd_HHmmss");
    return df.format(dt);
}

From source file:Main.java

@SuppressLint("SimpleDateFormat")
public static String getCurrentTime() {
    SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
    return timeFormat.format(new Date());
}

From source file:Main.java

public static boolean equalsMin(Date a, Date b) {
    SimpleDateFormat yearFormat = new SimpleDateFormat("yyyyMMddhhMM", locale);
    return yearFormat.format(a).equals(yearFormat.format(b));
}

From source file:Main.java

public static String getLastFridayofMonth(int offset) {
    final String DATE_FORMAT_NOW = "dd-MMM-yyyy";
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
    cal = getLastFriday(cal, offset);/*from  w  w  w .j ava2s.com*/
    return sdf.format(cal.getTime());
}

From source file:com.oic.utils.Tools.java

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

From source file:Main.java

public static String getDate(int hour, int min) {
    Date d = new Date();
    Calendar now = Calendar.getInstance();
    now.setTime(d);//from   ww w .j  a  v a  2  s  .  c o  m
    now.set(Calendar.HOUR, now.get(Calendar.HOUR) + hour);
    now.set(Calendar.MINUTE, now.get(Calendar.MINUTE) + min);

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH/mm");

    return sdf.format(now.getTime());
}

From source file:Main.java

public static String getFormartTime(String strFormart) {
    SimpleDateFormat formart = new SimpleDateFormat(strFormart, getLocale());
    return formart.format(new Date());
}

From source file:Main.java

/**
 * Convert date/*from  w  ww . ja va  2 s.c  o m*/
 * @param longtime
 * @return
 */
public static String convertTimeDatess(long longtime) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String str = sdf.format(longtime);
    return str;
}