@Override public Date resolveEndDate(String endDateString) { return ISODateTimeFormat.dateTimeParser().withZone(DateTimeZone.forTimeZone(clockReader.getCurrentTimeZone())).parseDateTime(endDateString).toCalendar(null).getTime(); }
switch (this.iso) { case DATE: dateTimeFormatter = ISODateTimeFormat.date(); break; case TIME: dateTimeFormatter = ISODateTimeFormat.time(); break; case DATE_TIME: dateTimeFormatter = ISODateTimeFormat.dateTime(); break; default: dateTimeFormatter = dateTimeFormatter.withZone(DateTimeZone.forTimeZone(this.timeZone));
private static DateTimeFormatter dateHour() { if (dh == null) { return new DateTimeFormatterBuilder() .append(date()) .append(literalTElement()) .append(hour()) .toFormatter(); } return dh; }
/** * Gets a debugging toString. * * @return a debugging string */ public String toString() { StringBuffer sb = new StringBuffer(60); sb.append("GJChronology"); sb.append('['); sb.append(getZone().getID()); if (iCutoverMillis != DEFAULT_CUTOVER.getMillis()) { sb.append(",cutover="); DateTimeFormatter printer; if (withUTC().dayOfYear().remainder(iCutoverMillis) == 0) { printer = ISODateTimeFormat.date(); } else { printer = ISODateTimeFormat.dateTime(); } printer.withChronology(withUTC()).printTo(sb, iCutoverMillis); } if (getMinimumDaysInFirstWeek() != 4) { sb.append(",mdfw="); sb.append(getMinimumDaysInFirstWeek()); } sb.append(']'); return sb.toString(); }
static void appendCacheLog(String namespace, URI resourceURI, File cacheDir, URI localResourceCacheURI) throws IOException { String accessedAt = ISODateTimeFormat.dateTime().withZoneUTC().print(new Date().getTime()); String sha256 = new File(localResourceCacheURI).getName(); CachedURI meta = new CachedURI(namespace, resourceURI, localResourceCacheURI, sha256, accessedAt); appendAccessLog(meta, getAccessFile(cacheDir)); }
public static Date parseDate(Object d, Date dflt) { if (d == null) return dflt; if (d instanceof Long) return new Date(((Long) d).longValue()); if (d instanceof String) return ISODateTimeFormat.dateOptionalTimeParser().parseDateTime((String) d).toDate(); if (d instanceof Date) return (Date) d; assert false; return dflt; }
@Override public String marshal(Date date) throws Exception { return ISODateTimeFormat.dateTime().withZoneUTC().print(new DateTime(date.getTime())); }
@Override public String marshal(Date date) throws Exception { return ISODateTimeFormat.dateTimeNoMillis().withZoneUTC().print(new DateTime(date.getTime())); }
@Override public String toString() { return "\"ISODate(" + ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).print(literal.getTime()) + ")\""; } }
public static String dateToString(Date date){ DateTimeFormatter fmt = ISODateTimeFormat.dateTimeNoMillis(); DateTime dateTime = new DateTime(date); return fmt.print(dateTime); } }
public String prepareRepeat(String dueDate, Clock clock) { if (dueDate.startsWith("R") && dueDate.split("/").length == 2) { DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); return dueDate.replace("/", "/" + fmt.print(new DateTime(clock.getCurrentTime(),DateTimeZone.forTimeZone(clock.getCurrentTimeZone()))) + "/"); } return dueDate; }
/** Example of running a query with timestamp query parameters. */ public void runQueryWithTimestampParameters() throws InterruptedException { // [START bigquery_query_params_timestamps] // BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); DateTime timestamp = new DateTime(2016, 12, 7, 8, 0, 0, DateTimeZone.UTC); String query = "SELECT TIMESTAMP_ADD(@ts_value, INTERVAL 1 HOUR);"; // Note: Standard SQL is required to use query parameters. QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query) .addNamedParameter( "ts_value", QueryParameterValue.timestamp( // Timestamp takes microseconds since 1970-01-01T00:00:00 UTC timestamp.getMillis() * 1000)) .build(); // Print the results. DateTimeFormatter formatter = ISODateTimeFormat.dateTimeNoMillis().withZoneUTC(); for (FieldValueList row : bigquery.query(queryConfig).iterateAll()) { System.out.printf( "%s\n", formatter.print( new DateTime( // Timestamp values are returned in microseconds since 1970-01-01T00:00:00 UTC, // but org.joda.time.DateTime constructor accepts times in milliseconds. row.get(0).getTimestampValue() / 1000, DateTimeZone.UTC))); System.out.printf("\n"); } // [END bigquery_query_params_timestamps] }
/** * Returns a formatted String representing the crawled date. * * @param waybackDate * @return */ protected static String parseCrawlDate( String waybackDate ) { DateTimeFormatter iso_df = ISODateTimeFormat.dateTimeNoMillis() .withZone(DateTimeZone.UTC); return iso_df.print(new org.joda.time.DateTime( getWaybackDate(waybackDate))); }
DateTimeFormatter dateTimeParser = ISODateTimeFormat.dateTimeParser(); dateTimeParser = dateTimeParser.withChronology(chrono); PeriodFormatter periodParser = ISOPeriodFormat.standard(); long startInstant = 0, endInstant = 0; period = periodParser.withParseType(getPeriodType(leftStr)).parsePeriod(leftStr); } else { DateTime start = dateTimeParser.parseDateTime(leftStr); startInstant = start.getMillis(); parsedChrono = start.getChronology(); endInstant = chrono.add(period, startInstant, 1); } else { DateTime end = dateTimeParser.parseDateTime(rightStr); endInstant = end.getMillis(); parsedChrono = (parsedChrono != null ? parsedChrono : end.getChronology()); chrono = (chrono != null ? chrono : parsedChrono); if (period != null) { startInstant = chrono.add(period, endInstant, -1);
new DateTime((System.currentTimeMillis() / 1000) * 1000, ISOChronology.getInstance()).withZone(DateTimeZone.UTC), new BigDecimal(123.45f).setScale(2, RoundingMode.HALF_DOWN) ); Assert.assertThat(withJsr310.getS(), is(withJoda.getS())); Assert.assertThat(ISO_LOCAL_DATE.format(withJsr310.getD()), is(ISODateTimeFormat.date().print(withJoda.getD()))); Assert.assertThat(ISO_LOCAL_TIME.format(withJsr310.getT()), is(ISODateTimeFormat.time().print(withJoda.getT()))); Assert.assertThat(ISO_INSTANT.format(withJsr310.getTs()), is(ISODateTimeFormat.dateTimeNoMillis().print(withJoda.getTs()))); Assert.assertThat(withJsr310.getDec(), comparesEqualTo(withJoda.getDec()));
@CheckForNull public static Date parseDateTime(@Nullable String s) { if (s == null) { return null; } return ISODateTimeFormat.dateTime().parseDateTime(s).toDate(); }