List of usage examples for java.text SimpleDateFormat format
public final String format(Date date)
From source file:Main.java
public static String getDateString(int year, int month, int day) { Calendar c = Calendar.getInstance(); c.set(year, month, day);/*from www . j a v a2 s . co m*/ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); return sdf.format(c.getTime()); }
From source file:Main.java
public static String timeStampToTime(long timeStamp) { SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); String date = sdf.format(timeStamp * 1000); return date;// w w w. j a v a 2s . co m }
From source file:Main.java
public static String getFormatDateTime(Date date, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); }
From source file:Main.java
public static String getCurrentDay() { Date NowDate = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("dd"); return formatter.format(NowDate); }
From source file:Main.java
public static String getCurrentMonth() { Date NowDate = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("MM"); return formatter.format(NowDate); }
From source file:Main.java
public static String getAlternateReadableDate(Date date) { SimpleDateFormat sdf = new SimpleDateFormat("MM/dd HH:mm:ss"); return sdf.format(date); }
From source file:Main.java
public static String formatDate(Date date, String pattern) { SimpleDateFormat format = new SimpleDateFormat(pattern); return format.format(date); }
From source file:Main.java
public static String getNowTime() { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); return sdf.format(Calendar.getInstance().getTime()); }
From source file:Main.java
public static String getDateWithFormat(Date date, String dateFormat) { SimpleDateFormat format = new SimpleDateFormat(dateFormat); return format.format(date); }
From source file:Main.java
public static String currentTime() { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); return df.format(new Date()); }