Example usage for org.joda.time LocalDateTime LocalDateTime

List of usage examples for org.joda.time LocalDateTime LocalDateTime

Introduction

In this page you can find the example usage for org.joda.time LocalDateTime LocalDateTime.

Prototype

public LocalDateTime(Object instant, Chronology chronology) 

Source Link

Document

Constructs an instance from an Object that represents a datetime, using the specified chronology.

Usage

From source file:edu.harvard.med.screensaver.io.workbook2.Cell.java

License:Open Source License

public static LocalDateTime convertGmtDateToLocalTimeZone(Date date) {
    return new LocalDateTime(date.getTime(), DateTimeZone.UTC);
}

From source file:fr.ybonnel.crawler.LanyrdCrawler.java

License:Apache License

public List<Schedule> crawl() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    if (cachesSchedules != null) {
        return cachesSchedules;
    }//from  w ww  . j a va2s . c  om
    Method starting = TestWatcher.class.getDeclaredMethod("starting", Description.class);
    starting.setAccessible(true);
    starting.invoke(this.lifecycle, Description.EMPTY);
    goTo("/");
    List<Schedule> schedules = new ArrayList<>();

    List<Speaker> allSpeakers = new ArrayList<>();
    for (FluentWebElement scheduleItem : find("li.schedule-item")) {
        Schedule schedule = new Schedule();
        schedule.setTitle(scheduleItem.find("h2 a").getText());
        schedule.setUrl(scheduleItem.find("h2 a").getAttribute("href"));
        schedule.setDescription(scheduleItem.find("div.desc").getText());

        String startDate = scheduleItem.find("span.dtstart span.value-title").getAttribute("title");
        String endDate = scheduleItem.find("span.dtend span.value-title").getAttribute("title");

        schedule.setBeginDate(
                new LocalDateTime(startDate.replace("+ZZ:ZZ", ""), DateTimeZone.forID("Europe/Paris"))
                        .toDate());
        schedule.setEndDate(
                new LocalDateTime(endDate.replace("+ZZ:ZZ", ""), DateTimeZone.forID("Europe/Paris")).toDate());

        schedule.setRoom(
                scheduleItem.find("div.schedule-meta div p", 1).getText().split("\n")[1].split(",")[0]);

        schedules.add(schedule);
    }

    for (Schedule schedule : schedules) {
        goTo(schedule.getUrl());
        for (FluentWebElement profileItem : find("div.primary div.mini-profile")) {
            Speaker speaker = new Speaker();
            speaker.setAvatar(profileItem.find("div.avatar a img").getAttribute("src"));
            speaker.setName(profileItem.find("span.name a").getText());
            speaker.setBio(profileItem.find("div.profile-longdesc p").getText());
            schedule.getSpeakers().add(speaker);
        }

    }
    getDriver().quit();
    cachesSchedules = schedules;
    return schedules;
}

From source file:org.alfresco.bm.devicesync.dao.mongo.MongoMetricsService.java

License:Open Source License

@Override
public void addMetrics(DBObject syncMetrics, DBObject activeMQStats) {
    long timestamp = System.currentTimeMillis();
    LocalDateTime time = new LocalDateTime(timestamp, DateTimeZone.UTC);
    String formattedTime = time.toString();

    DBObject insert = BasicDBObjectBuilder.start("timestamp", timestamp).add("time", formattedTime)
            .add("sync", syncMetrics).add("activeMQ", activeMQStats).get();
    collection.insert(insert);/* ww w.  j a  v a 2  s . c  om*/
}

From source file:org.apache.calcite.adapter.druid.LocalInterval.java

License:Apache License

/** Writes a value such as "1900-01-01T00:00:00.000/2015-10-12T00:00:00.000".
 * Note that there are no "Z"s; the value is in the (unspecified) local
 * time zone, not UTC. *//*w ww  . j  a  v  a2 s  .  c o  m*/
@Override
public String toString() {
    final LocalDateTime start = new LocalDateTime(this.start, ISOChronology.getInstanceUTC());
    final LocalDateTime end = new LocalDateTime(this.end, ISOChronology.getInstanceUTC());
    return start + "/" + end;
}

From source file:org.apache.isis.applib.clock.Clock.java

License:Apache License

public static LocalDateTime getTimeAsLocalDateTime() {
    return new LocalDateTime(getTime(), Defaults.getTimeZone());
}

From source file:org.openhat.opdi.units.UnitFormat.java

License:Open Source License

public LocalDateTime convertToLocalDate(long value) {
    if ("unixSeconds".equals(conversion)) {
        return new LocalDateTime(value * 1000, DateTimeZone.UTC);
    } else if ("unixSecondsLocal".equals(conversion)) {
        return new LocalDateTime(value * 1000);
    } else//from w w  w  .ja  v a 2  s .co  m
        throw new RuntimeException("UnitFormat: Conversion not supported: " + conversion);
}

From source file:se.inera.certificate.schema.adapter.LocalDateAdapter.java

License:Open Source License

/**
 * Converts an xs:datetime to a Joda Time LocalDateTime.
 *///from  ww w  .j  a  v  a  2  s . co m
public static LocalDateTime parseDateTime(String dateTimeString) {
    // Workaround for the fact that DatatypeConverter doesn't allow setting the default TimeZone,
    // (which means that the system default TimeZone will be used, which might be wrong if hosted in
    // a different TimeZone), and that LocalDateTime doesn't handle datetimes with explicit TimeZone.
    // Hence if the date contains an explicit TimeZone, use DatatypeConverter to do the parsing,
    // otherwise use LocalDateTime's parsing.
    if (dateTimeString.matches(XSD_DATETIME_TIMEZONE_REGEXP)
            || dateTimeString.matches(XSD_DATE_TIMEZONE_REGEXP)) {
        return new LocalDateTime(javax.xml.bind.DatatypeConverter.parseDateTime(dateTimeString).getTime(),
                TIME_ZONE);
    } else {
        return new LocalDateTime(dateTimeString, TIME_ZONE);
    }
}