List of usage examples for java.text DateFormat format
public final String format(Date date)
From source file:Main.java
public static String parserTimestamp(Timestamp timestamp) { String tsStr = ""; DateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); try {/*from w w w . jav a 2 s. c o m*/ tsStr = sdf.format(timestamp); } catch (Exception e) { e.printStackTrace(); } return tsStr; }
From source file:elaborate.editor.backend.Indexer.java
public static String convert(long ms) { Date date = new Date(ms - (1000 * 60 * 60)); DateFormat formatter = new SimpleDateFormat("HH:mm:ss:SSS"); return formatter.format(date); }
From source file:Main.java
public final static String now() { TimeZone tz = TimeZone.getTimeZone("UTC"); DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); df.setTimeZone(tz);/* ww w . ja v a 2 s.c o m*/ return df.format(new Date()); }
From source file:Main.java
/** * Gets the day of week out of a date./*from w w w . j a va 2 s . co m*/ * * @param dateString represents the date. * @return the day of week of the date. */ public static String dateToDayOfWeek(String dateString) { Date date = new Date(); try { date = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.GERMAN).parse(dateString); } catch (ParseException e) { e.printStackTrace(); } DateFormat dtfmt = new SimpleDateFormat("EEE", Locale.ENGLISH); String dayOfWeek = dtfmt.format(date); return dayOfWeek; }
From source file:Main.java
public static String getHoraAtual() { DateFormat df = new SimpleDateFormat("HH:mm"); Calendar cal = Calendar.getInstance(); return df.format(cal.getTime()); }
From source file:Main.java
public static String formatTime(Context context, Date dateToFormat) { java.text.DateFormat df = android.text.format.DateFormat.getTimeFormat(context); return df.format(dateToFormat); }
From source file:Main.java
public static String formatTimestamp(long timestamp) { DateFormat dtf = new SimpleDateFormat("HH:mm:ss"); dtf.setTimeZone(TimeZone.getDefault()); return dtf.format(new Date(timestamp)); }
From source file:Main.java
public static String getTodaysDate() { DateFormat dateFormat = new SimpleDateFormat(URL_DATE_FORMAT); Date date = new Date(); return dateFormat.format(date); }
From source file:Main.java
public static String getFormattedString(Calendar calendar) { DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); Date date = calendar.getTime(); return dateFormat.format(date); }
From source file:DateUtils.java
/** * A method to get the current date to use in a timestamp * * @return a string containing the timestamp *//*from w w w . ja v a 2 s . c om*/ public static String getCurrentDate() { GregorianCalendar calendar = new GregorianCalendar(); DateFormat formatter = DateFormat.getDateInstance(DateFormat.FULL); return formatter.format(calendar.getTime()); }