@Test public void testFormatUTC() { final Calendar c = Calendar.getInstance(FastTimeZone.getGmtTimeZone()); c.set(2005, Calendar.JANUARY, 1, 12, 0, 0); assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern())); assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime().getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern())); assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), Locale.US)); assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime().getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), Locale.US)); }
public String humanizeTimestamp(long timestamp) { if (taskDatePattern.isPresent() && timeZone.isPresent()) { return DateFormatUtils.format(timestamp, taskDatePattern.get(), timeZone.get()); } else if (taskDatePattern.isPresent()) { return DateFormatUtils.formatUTC(timestamp, taskDatePattern.get()); } else if (timeZone.isPresent()) { return DateFormatUtils.format(timestamp, DEFAULT_TIMESTAMP_FORMAT, timeZone.get()); } else { return DateFormatUtils.format(timestamp, DEFAULT_TIMESTAMP_FORMAT); } }
/** * <p>Formats a date/time into a specific pattern using the UTC time zone.</p> * * @param millis the date to format expressed in milliseconds * @param pattern the pattern to use to format the date, not null * @param locale the locale to use, may be <code>null</code> * @return the formatted date */ public static String formatUTC(long millis, String pattern, Locale locale) { return DateFormatUtils.formatUTC(millis, pattern, locale); }
/** * <p>Formats a date/time into a specific pattern using the UTC time zone.</p> * * @param date the date to format, not null * @param pattern the pattern to use to format the date, not null * @return the formatted date */ public static String formatUTC(Date date, String pattern) { return DateFormatUtils.formatUTC(date, pattern); }
/** * <p>Formats a date/time into a specific pattern using the UTC time zone.</p> * * @param millis the date to format expressed in milliseconds * @param pattern the pattern to use to format the date, not null * @return the formatted date */ public static String formatUTC(long millis, String pattern) { return DateFormatUtils. formatUTC(millis, pattern); }
/** * <p>Formats a date/time into a specific pattern using the UTC time zone.</p> * * @param date the date to format, not null * @param pattern the pattern to use to format the date, not null * @param locale the locale to use, may be <code>null</code> * @return the formatted date */ public static String formatUTC(Date date, String pattern, Locale locale) { return DateFormatUtils.formatUTC(date, pattern, locale); }
/** * @param date */ protected static String formatDateWithMillis(Calendar date) { return DateFormatUtils.formatUTC(date.getTimeInMillis(), "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); //$NON-NLS-1$ }
/** * @param date */ protected static String formatDate(Calendar date) { return DateFormatUtils.formatUTC(date.getTimeInMillis(), "yyyy-MM-dd'T'HH:mm:ss'Z'"); //$NON-NLS-1$ }
public String humanizeTimestamp(long timestamp) { if (taskDatePattern.isPresent() && timeZone.isPresent()) { return DateFormatUtils.format(timestamp, taskDatePattern.get(), timeZone.get()); } else if (taskDatePattern.isPresent()) { return DateFormatUtils.formatUTC(timestamp, taskDatePattern.get()); } else if (timeZone.isPresent()) { return DateFormatUtils.format(timestamp, DEFAULT_TIMESTAMP_FORMAT, timeZone.get()); } else { return DateFormatUtils.format(timestamp, DEFAULT_TIMESTAMP_FORMAT); } }
/** * Returns the value in Json Format */ @Override public JsonElement toJsonObject() { String utcTime = DateFormatUtils.formatUTC(getValue(), DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()); return (JsonElement) new JsonPrimitive(utcTime); }
/** * Returns the value in Json Format */ @Override public JsonElement toJsonObject() { String utcTime = DateFormatUtils.formatUTC(getValue(), DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()); return (JsonElement) new JsonPrimitive(utcTime); }
date = new Date(); String utcTime = DateFormatUtils.formatUTC(date, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern());
date = new Date(); String utcTime = DateFormatUtils.formatUTC(date, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern());
log.add("message", new JsonPrimitive(message)); log.add("severity", new JsonPrimitive(severity.getSeverity())); String utcTime = DateFormatUtils.formatUTC(timestamp, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()); log.add("timestamp", new JsonPrimitive(utcTime));
log.add("message", new JsonPrimitive(message)); log.add("severity", new JsonPrimitive(severity.getSeverity())); String utcTime = DateFormatUtils.formatUTC(timestamp, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()); log.add("timestamp", new JsonPrimitive(utcTime));
json.addProperty("elevation", elevation); String utcTime = DateFormatUtils.formatUTC(measuredDateTime, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()); json.addProperty("measuredDateTime", utcTime);
log.add("message", new JsonPrimitive(message)); log.add("severity", new JsonPrimitive(severity.getSeverity())); String utcTime = DateFormatUtils.formatUTC(timestamp, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()); log.add("timestamp", new JsonPrimitive(utcTime));
json.addProperty("elevation", elevation); String utcTime = DateFormatUtils.formatUTC(measuredDateTime, DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()); json.addProperty("measuredDateTime", utcTime);
/** * Return the <code>JsonObject</code> representation of the <code>DeviceLocation</code> object. * @return JsonObject object */ public JsonObject toJsonObject() { JsonObject json = new JsonObject(); json.addProperty(this.latitude.getResourceName(), latitude.getValue()); json.addProperty(this.longitude.getResourceName(), longitude.getValue()); if(elevation != null) { json.addProperty(this.elevation.getResourceName(), elevation.getValue()); } String utcTime = DateFormatUtils.formatUTC(measuredDateTime.getValue(), DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()); json.addProperty(this.measuredDateTime.getResourceName(), utcTime); if(accuracy != null) { json.addProperty(this.accuracy.getResourceName(), accuracy.getValue()); } return json; }
/** * Return the <code>JsonObject</code> representation of the <code>DeviceLocation</code> object. * @return JsonObject object */ public JsonObject toJsonObject() { JsonObject json = new JsonObject(); json.addProperty(this.latitude.getResourceName(), latitude.getValue()); json.addProperty(this.longitude.getResourceName(), longitude.getValue()); if(elevation != null) { json.addProperty(this.elevation.getResourceName(), elevation.getValue()); } String utcTime = DateFormatUtils.formatUTC(measuredDateTime.getValue(), DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern()); json.addProperty(this.measuredDateTime.getResourceName(), utcTime); if(accuracy != null) { json.addProperty(this.accuracy.getResourceName(), accuracy.getValue()); } return json; }