List of usage examples for java.text SimpleDateFormat format
public final String format(Date date)
From source file:Main.java
public static String getToday() { Date currentTime = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM"); String dateString = formatter.format(currentTime); return dateString; }
From source file:Main.java
public static String convertDateFormat(String datetime) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss+0000"); Date testDate = null;// w w w . j av a 2 s . com try { testDate = sdf.parse(datetime); } catch (Exception ex) { ex.printStackTrace(); } SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd"); return formatter.format(testDate); }
From source file:Main.java
public static String getTime() { SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); return format.format(new Date()); }
From source file:Main.java
public static String formatDate(Date date) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); return formatter.format(date); }
From source file:Main.java
public static String calendarToShortDateBr(Calendar data) { SimpleDateFormat sdf = new SimpleDateFormat("MMM/yyyy", Locale.getDefault()); return sdf.format(data.getTime()); }
From source file:Main.java
final static String getDateTime() { SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd-hhmmss"); return df.format(Calendar.getInstance().getTime()); }
From source file:Main.java
public static String getCurrentDate() { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); String currentDate = format.format(new Date()); return currentDate; }
From source file:Main.java
public static String getDate(Long timestamp) { Date date = new Date(timestamp); SimpleDateFormat dateformat = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss"); return (dateformat.format(date)); }
From source file:Main.java
@SuppressLint("SimpleDateFormat") public static String dateFormat(String dateTime) { Date date = new Date(Long.parseLong(dateTime)); SimpleDateFormat myFormat = new SimpleDateFormat("yyyy-MM-dd"); String time = myFormat.format(date); return time;/*from w w w . j ava 2 s. c o m*/ }
From source file:Main.java
public static String getTimeStringByCalendar(Calendar calendar) { SimpleDateFormat sdf = new SimpleDateFormat(FORMAT_TIME); final String timeString = sdf.format(calendar.getTime()) + "00"; return timeString; }