List of usage examples for java.text DateFormat format
public final String format(Date date)
From source file:com.kku.apps.pricesearch.util.SignedHelper.java
private static String timestamp() { String timestamp = null;/*w w w . j a va 2 s. c om*/ Calendar cal = Calendar.getInstance(); DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); dfm.setTimeZone(TimeZone.getTimeZone("GMT")); timestamp = dfm.format(cal.getTime()); return timestamp; }
From source file:org.ebaysf.ostara.upgrade.util.GitUtils.java
private static String getISODate(int i) { DateFormat df = new SimpleDateFormat("YYYY-MM-dd"); Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, -i);/*from w w w . jav a2s.c o m*/ String date = df.format(cal.getTime()); return date; }
From source file:com.collabnet.ccf.core.utils.DateUtil.java
/** * Converts the given Date object into another date object with the * specified time zone information.//from ww w . jav a 2 s .c o m * * @param date * - The date that is to be converted to a different time zone. * @param toTimeZone * - the time zone to which the date object should be converted. * @return the new Date object in the specified time zone. * @throws ParseException */ public static Date convertDate(Date date, String toTimeZone) throws ParseException { Calendar cal = new GregorianCalendar(TimeZone.getTimeZone(toTimeZone)); cal.setTime(date); DateFormat df = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss.SSS Z"); df.setCalendar(cal); return df.parse(df.format(cal.getTime())); }
From source file:com.augmentum.common.util.DateUtil.java
public static String getDate(Date date, String pattern, Locale locale) { DateFormat dateFormat = new SimpleDateFormat(pattern, locale); return dateFormat.format(date); }
From source file:model.NotesImageFile.java
/** * Takes a regular filename and creates a unique filename with date values included * @param fileName - the plain filename// ww w. j a va 2s.com * @return */ public static String createUniqueFileName(String fileName) { int hashcode = fileName.hashCode(); DateFormat df = new SimpleDateFormat("yyyy-mm-dd-HH-mm-ss"); Calendar calobj = Calendar.getInstance(); System.out.println(df.format(calobj.getTime())); return (df.format(calobj.getTime()) + hashcode + fileName); }
From source file:Main.java
/** * Return a timestamp/*from w w w.ja v a 2 s.co m*/ * * @param context Application Context */ @SuppressWarnings("UnnecessaryFullyQualifiedName") public static String getTimestamp(Context context) { String timestamp = "unknown"; Date now = new Date(); java.text.DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(context); java.text.DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(context); if (dateFormat != null && timeFormat != null) { timestamp = dateFormat.format(now) + ' ' + timeFormat.format(now); } return timestamp; }
From source file:flusim.XY_Plotter.java
private static String getDateTime() { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); Date date = new Date(); return dateFormat.format(date); }
From source file:com.box.boxjavalibv2.utils.ISO8601DateParser.java
public static String toString(Date date) { DateFormat df = mThreadLocalSimpleDateFormat.get(); TimeZone tz = TimeZone.getTimeZone("UTC"); df.setTimeZone(tz);//from w w w . j a v a 2s . co m String output = df.format(date); String result = output.replaceAll("UTC", "+00:00"); return result; }
From source file:lucee.runtime.converter.JSONDateFormat.java
public synchronized static String format(Date date, TimeZone tz) { tz = ThreadLocalPageContext.getTimeZone(tz); String id = locale.hashCode() + "-" + tz.getID(); DateFormat format = (DateFormat) map.get(id); if (format == null) { format = new SimpleDateFormat("MMMM, dd yyyy HH:mm:ss Z", locale); format.setTimeZone(tz);//from w ww . ja v a 2s.c o m map.put(id, format); } return format.format(date); }
From source file:com.hangum.tadpole.engine.query.sql.TadpoleSystem_SchemaHistory.java
/** * Get schema history data./*from w w w . j a v a 2s. c o m*/ * * @param dbSeq * @param workType * @param objectType * @param objectId * @param startTime * @param endTime * @return * @throws Exception */ public static List<SchemaHistoryDAO> getExecuteQueryHistory(int dbSeq, String workType, String objectType, String objectId, long startTime, long endTime) throws Exception { List<SchemaHistoryDAO> returnSchemaHistory = new ArrayList<SchemaHistoryDAO>(); Map<String, Object> queryMap = new HashMap<String, Object>(); queryMap.put("db_seq", dbSeq); queryMap.put("workType", "%" + workType + "%"); queryMap.put("objectType", "%" + objectType + "%"); queryMap.put("objectId", "%" + objectId + "%"); if (ApplicationArgumentUtils.isDBServer()) { Date date = new Date(startTime); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"); queryMap.put("startTime", formatter.format(date)); Date dateendTime = new Date(endTime); queryMap.put("endTime", formatter.format(dateendTime)); } else { queryMap.put("startTime", startTime); queryMap.put("endTime", endTime); } SqlMapClient sqlClient = TadpoleSQLManager.getInstance(TadpoleSystemInitializer.getUserDB()); returnSchemaHistory = sqlClient.queryForList("getSchemaHistory", queryMap); return returnSchemaHistory; }