Package org.joda.time

Examples of org.joda.time.DateTime


    int month,
    int day,
    int hour,
    int minute,
    int second) {
    return new DateTime(year, month, day, hour, minute, second, 0).withZone(DateTimeZone.UTC);
  }
View Full Code Here


    public static Html timestampShortTZ(DateTime instant) {
        return timestampShortTZ(instant, true);
    }

    public static Html timestampShortTZ(DateTime instant, boolean inUserTZ) {
        DateTime date = instant;

        if (inUserTZ) {
            date = DateTools.inUserTimeZone(instant);
        }
        return views.html.partials.dates.instant.render(date, DateTools.SHORT_DATE_FORMAT_TZ);
View Full Code Here

    protected static Call prepareNonStreamBoundReplayRoute(String query, TimeRange timerange) {
        return routes.SearchController.index(
                (query == null) ? "" : query,
                timerange.getType().name().toLowerCase(),
                timerange.getQueryParams().containsKey("range") ? Integer.valueOf(timerange.nullSafeParam("range")) : 0,
                timerange.getQueryParams().containsKey("from") ? new DateTime(timerange.nullSafeParam("from")).toString(DateTools.SHORT_DATE_FORMAT) : "",
                timerange.getQueryParams().containsKey("to") ? new DateTime(timerange.nullSafeParam("to")).toString(DateTools.SHORT_DATE_FORMAT) : "",
                timerange.nullSafeParam("keyword"),
                "minute",
                0,
                "",
                "",
View Full Code Here

        return routes.StreamSearchController.index(
                streamId,
                (query == null) ? "" : query,
                timerange.getType().name().toLowerCase(),
                timerange.getQueryParams().containsKey("range") ? Integer.valueOf(timerange.nullSafeParam("range")) : 0,
                timerange.getQueryParams().containsKey("from") ? new DateTime(timerange.nullSafeParam("from")).toString(DateTools.SHORT_DATE_FORMAT) : "",
                timerange.getQueryParams().containsKey("to") ? new DateTime(timerange.nullSafeParam("to")).toString(DateTools.SHORT_DATE_FORMAT) : "",
                timerange.nullSafeParam("keyword"),
                "minute",
                0,
                "",
                "",
View Full Code Here

        }
    }

    private static abstract class Pig11OrHigherConverter {
        static String convertToES(Object pigDate) {
            DateTime dt = (DateTime) pigDate;
            // ISODateTimeFormat.dateOptionalTimeParser() throws "printing not supported"
            return dt.toString();
        }
View Full Code Here

        static Object convertFromES(String esDate) {
            return ISODateTimeFormat.dateOptionalTimeParser().parseDateTime(esDate);
        }

        static Object convertFromES(Long esDate) {
            return new DateTime(esDate, DateTimeZone.UTC);
        }
View Full Code Here

   * boundaries. This implementation tries to "do what I mean".
   * @param ts RFC3164-compatible timestamp to be parsed
   * @return Typical (for Java) milliseconds since the UNIX epoch
   */
  protected long parseRfc3164Time(String ts) {
    DateTime now = DateTime.now();
    int year = now.getYear();

    ts = TWO_SPACES.matcher(ts).replaceFirst(" ");

    DateTime date;
    try {
      date = rfc3164Format.parseDateTime(ts);
    } catch (IllegalArgumentException e) {
      logger.debug("rfc3164 date parse failed on ("+ts+"): invalid format", e);
      return 0;
    }

    // try to deal with boundary cases, i.e. new year's eve.
    // rfc3164 dates are really dumb.
    // NB: cannot handle replaying of old logs or going back to the future
    if (date != null) {
      DateTime fixed = date.withYear(year);

      // flume clock is ahead or there is some latency, and the year rolled
      if (fixed.isAfter(now) && fixed.minusMonths(1).isAfter(now)) {
        fixed = date.withYear(year - 1);
      // flume clock is behind and the year rolled
      } else if (fixed.isBefore(now) && fixed.plusMonths(1).isBefore(now)) {
        fixed = date.withYear(year + 1);
      }
      date = fixed;
    }

View Full Code Here

    private static final DateTimeFormatter RFC_1123_DATE_TIME = DateTimeFormat.forPattern("EEE, dd MMM yyyy HH:mm:ss 'GMT'").withZoneUTC();

    @Override
    public F.Promise<Result> call(Http.Context context) throws Throwable {
        context.response().setHeader("Server", "play2-java-jpa");
        context.response().setHeader("Date", RFC_1123_DATE_TIME.print(new DateTime()));
        return delegate.call(context);
    }
View Full Code Here

        assertEquals(true, julian.millisOfSecond().isSupported());
    }

    public void testLeap_28feb() {
        Chronology chrono = JulianChronology.getInstance();
        DateTime dt = new DateTime(2012, 2, 28, 0, 0, chrono);
        assertEquals(true, dt.year().isLeap());
        assertEquals(true, dt.monthOfYear().isLeap());
        assertEquals(false, dt.dayOfMonth().isLeap());
        assertEquals(false, dt.dayOfYear().isLeap());
    }
View Full Code Here

        assertEquals(false, dt.dayOfYear().isLeap());
    }

    public void testLeap_29feb() {
        Chronology chrono = JulianChronology.getInstance();
        DateTime dt = new DateTime(2012, 2, 29, 0, 0, chrono);
        assertEquals(true, dt.year().isLeap());
        assertEquals(true, dt.monthOfYear().isLeap());
        assertEquals(true, dt.dayOfMonth().isLeap());
        assertEquals(true, dt.dayOfYear().isLeap());
    }
View Full Code Here

TOP

Related Classes of org.joda.time.DateTime

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.