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 convertTime2DateyMd(long longtime) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd");
    String str = sdf.format(longtime);
    return str;//  w  w  w  .ja  v  a 2  s .  c o m
}

From source file:Main.java

public static boolean isSameDay(long day1, long day2) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
    String str1 = sdf.format(new Date(day1));
    String str2 = sdf.format(new Date(day2));
    if (str1.equals(str2)) {
        return true;
    }/*  ww  w.  j  a  va  2  s  .c o  m*/
    return false;
}

From source file:Main.java

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

From source file:Main.java

public static String formatData(String time) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    return format.format(new Date(Long.parseLong(time)));
}

From source file:Main.java

public static String millis2FormatString(String format, Long millis) {
    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.getDefault());
    return sdf.format(new Date(millis));
}

From source file:Main.java

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

From source file:Main.java

/**
 * Converts java Date class into XSDdateTime format.
 * @param timeStamp/* ww w.  java 2 s . c om*/
 * @return
 */
public static String toXSD(Date timeStamp) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    return sdf.format(timeStamp);
}

From source file:Main.java

public static void updateLabel(EditText et, Calendar calendar) {
    String format = "dd/MM/yyyy";
    SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
    et.setText(sdf.format(calendar.getTime()));
}

From source file:Main.java

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

}

From source file:Main.java

/**
 *
 * @return/*w  ww.j  a v a  2s . c  o  m*/
 */
public static String tomorrow() {
    GregorianCalendar gc = new GregorianCalendar();
    gc.setTime(new Date());
    gc.add(GregorianCalendar.DATE, 1);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

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