@Override protected DateFormat initialValue() { // Date format specified by RFC 7231 section 7.1.1.1. DateFormat rfc1123 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US); rfc1123.setLenient(false); rfc1123.setTimeZone(UTC); return rfc1123; } };
private static String clientDateString() { TimeZone tz = TimeZone.getTimeZone("UTC"); DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); df.setTimeZone(tz); // strip timezone return df.format(new Date()); }
/** * @{inheritDoc} */ public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { dateFormat.setTimeZone(TimeZone.getDefault()); return dateFormat.format(date, toAppendTo, fieldPosition); }
Date result = STANDARD_DATE_FORMAT.get().parse(value, position); if (position.getIndex() == value.length()) { DateFormat format = BROWSER_COMPATIBLE_DATE_FORMATS[i]; if (format == null) { format = new SimpleDateFormat(BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS[i], Locale.US); format.setTimeZone(UTC); BROWSER_COMPATIBLE_DATE_FORMATS[i] = format; result = format.parse(value, position); if (position.getIndex() != 0) {
SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US); format.setTimeZone(TimeZone.getTimeZone("UTC"));
public void write(JSONSerializer serializer, Object object, BeanContext context) throws IOException { SerializeWriter out = serializer.out; String format = context.getFormat(); Calendar calendar = (Calendar) object; if (format.equals("unixtime")) { long seconds = calendar.getTimeInMillis() / 1000L; out.writeInt((int) seconds); return; } DateFormat dateFormat = new SimpleDateFormat(format); if (dateFormat == null) { dateFormat = new SimpleDateFormat(JSON.DEFFAULT_DATE_FORMAT, serializer.locale); dateFormat.setTimeZone(serializer.timeZone); } String text = dateFormat.format(calendar.getTime()); out.writeString(text); }
localSimpleDateFormat = new ThreadLocal<SimpleDateFormat>() { protected SimpleDateFormat initialValue() { return new SimpleDateFormat(); localSimpleDateFormat = new ThreadLocal<SimpleDateFormat>() { protected SimpleDateFormat initialValue() { return new SimpleDateFormat(pattern); localSimpleDateFormat = new ThreadLocal<SimpleDateFormat>() { protected SimpleDateFormat initialValue() { return new SimpleDateFormat(pattern, formatSymbols); return localSimpleDateFormat.get().parse(source); localSimpleDateFormat.get().setTimeZone(zone);
public static Date parseDate(String dateString) { // 2015-04-13T07:56:36.185Z format.setTimeZone(TimeZone.getTimeZone("GMT")); try { return format.parse(dateString); } catch (ParseException e) { return null; } } }
public void activateOptions() { setDateFormat(dateFormatOption); if(timeZoneID != null && dateFormat != null) { dateFormat.setTimeZone(TimeZone.getTimeZone(timeZoneID)); } }
SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss"); dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT")); //Local time zone SimpleDateFormat dateFormatLocal = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss"); //Time in GMT return dateFormatLocal.parse( dateFormatGmt.format(new Date()) );
Date result = STANDARD_DATE_FORMAT.get().parse(value, position); if (position.getIndex() == value.length()) { DateFormat format = BROWSER_COMPATIBLE_DATE_FORMATS[i]; if (format == null) { format = new SimpleDateFormat(BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS[i], Locale.US); format.setTimeZone(UTC); BROWSER_COMPATIBLE_DATE_FORMATS[i] = format; result = format.parse(value, position); if (position.getIndex() != 0) {
@Override protected DateFormat initialValue() { // Date format specified by RFC 7231 section 7.1.1.1. DateFormat rfc1123 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US); rfc1123.setLenient(false); rfc1123.setTimeZone(UTC); return rfc1123; } };
private static DateFormat getDateFormat() { DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_STRING); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return dateFormat; }
String format( Date date, TimeZone timeZone ) { DateFormat dateFormat = get(); dateFormat.setTimeZone( timeZone ); return dateFormat.format( date ); }
protected void init() { // Use RFC3339 format for date and datetime. // See http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14 this.dateFormat = new RFC3339DateFormat(); // Use UTC as the default time zone. this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); // Set default User-Agent. setUserAgent("Java-SDK"); // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap<String, Authentication>(); authentications.put("api_key", new ApiKeyAuth("header", "api_key")); authentications.put("petstore_auth", new OAuth()); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); }
TimeZone tz = TimeZone.getTimeZone("UTC"); DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'"); df.setTimeZone(tz); String nowAsISO = df.format(new Date());
/** * Sets the executionTime which is in standard format ({@link #SIGNATURE_TIME_FORMAT}) * @param executionTime the execution time * * @since POI 4.0.0 */ public void setExecutionTime(String executionTime) { if (executionTime != null && !"".equals(executionTime)){ final DateFormat fmt = new SimpleDateFormat(SIGNATURE_TIME_FORMAT, Locale.ROOT); fmt.setTimeZone(LocaleUtil.TIMEZONE_UTC); try { this.executionTime = fmt.parse(executionTime); } catch (ParseException e) { LOG.log(POILogger.WARN, "Illegal execution time: "+executionTime); } } }
public static DateFormat getOutDateFormatter() { DateFormat f = new SimpleDateFormat(SvnCommand.SVN_DATE_FORMAT_OUT); f.setTimeZone(UTC); return f; }
SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); isoFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date date = isoFormat.parse("2010-05-23T09:01:02");
Date result = STANDARD_DATE_FORMAT.get().parse(value, position); if (position.getIndex() == value.length()) { DateFormat format = BROWSER_COMPATIBLE_DATE_FORMATS[i]; if (format == null) { format = new SimpleDateFormat(BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS[i], Locale.US); format.setTimeZone(UTC); BROWSER_COMPATIBLE_DATE_FORMATS[i] = format; result = format.parse(value, position); if (position.getIndex() != 0) {