Example usage for org.joda.time DateTime DateTime

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

Introduction

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

Prototype

public DateTime(Object instant) 

Source Link

Document

Constructs an instance from an Object that represents a datetime.

Usage

From source file:ca.ualberta.physics.cssdp.jaxb.DateTimeAdapter.java

License:Apache License

public DateTime unmarshal(String v) throws Exception {
    return new DateTime(v);
}

From source file:carrental.beans.billing.BillingBean.java

private int simulateDaysUsed(ReturnProtocol returnProtocol) {
    DateTime newReturnDate = new DateTime(simulateReturnDate(returnProtocol));
    DateTime reservationDate = new DateTime(returnProtocol.getReservationDate().getTime());
    return Days.daysBetween(reservationDate.withTimeAtStartOfDay(), newReturnDate.withTimeAtStartOfDay())
            .getDays();//  w  w w.  j av  a 2  s. com
}

From source file:cd.education.data.collector.android.widgets.DateTimeWidget.java

License:Apache License

private void setAnswer() {

    if (mPrompt.getAnswerValue() != null) {

        DateTime ldt = new DateTime(((Date) ((DateTimeData) mPrompt.getAnswerValue()).getValue()).getTime());
        mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener);
        mTimePicker.setCurrentHour(ldt.getHourOfDay());
        mTimePicker.setCurrentMinute(ldt.getMinuteOfHour());

    } else {/* w ww .  j av  a 2  s  . co  m*/
        // create time widget with current time as of right now
        clearAnswer();
    }
}

From source file:cd.education.data.collector.android.widgets.DateWidget.java

License:Apache License

private void setAnswer() {

    if (mPrompt.getAnswerValue() != null) {
        DateTime ldt = new DateTime(((Date) ((DateData) mPrompt.getAnswerValue()).getValue()).getTime());
        mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener);
    } else {//from   w w w .ja  v  a  2s  .  co m
        // create date widget with current time as of right now
        clearAnswer();
    }
}

From source file:cd.education.data.collector.android.widgets.TimeWidget.java

License:Apache License

public TimeWidget(Context context, final FormEntryPrompt prompt) {
    super(context, prompt);

    mTimePicker = new TimePicker(getContext());
    mTimePicker.setId(QuestionWidget.newUniqueId());
    mTimePicker.setFocusable(!prompt.isReadOnly());
    mTimePicker.setEnabled(!prompt.isReadOnly());

    String clockType = android.provider.Settings.System.getString(context.getContentResolver(),
            android.provider.Settings.System.TIME_12_24);
    if (clockType == null || clockType.equalsIgnoreCase("24")) {
        mTimePicker.setIs24HourView(true);
    }//from ww w .  j  a va2  s.co  m

    // If there's an answer, use it.
    if (prompt.getAnswerValue() != null) {

        // create a new date time from date object using default time zone
        DateTime ldt = new DateTime(((Date) ((TimeData) prompt.getAnswerValue()).getValue()).getTime());
        System.out.println("retrieving:" + ldt);

        mTimePicker.setCurrentHour(ldt.getHourOfDay());
        mTimePicker.setCurrentMinute(ldt.getMinuteOfHour());

    } else {
        // create time widget with current time as of right now
        clearAnswer();
    }

    mTimePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
        @Override
        public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
            Collect.getInstance().getActivityLogger().logInstanceAction(TimeWidget.this, "onTimeChanged",
                    String.format("%1$02d:%2$02d", hourOfDay, minute), mPrompt.getIndex());
        }
    });

    setGravity(Gravity.LEFT);
    addView(mTimePicker);

}

From source file:cd.go.contrib.elasticagents.docker.DockerContainer.java

License:Apache License

public DockerContainer(String name, Date createdAt, Map<String, String> properties, String environment) {
    this.name = name;
    this.createdAt = new DateTime(createdAt);
    this.properties = properties;
    this.environment = environment;
}

From source file:cd.go.contrib.elasticagents.docker.DockerContainers.java

License:Apache License

private DockerContainers unregisteredAfterTimeout(PluginSettings settings, Agents knownAgents)
        throws Exception {
    Period period = settings.getAutoRegisterPeriod();
    DockerContainers unregisteredContainers = new DockerContainers();

    for (String containerName : instances.keySet()) {
        if (knownAgents.containsAgentWithId(containerName)) {
            continue;
        }/*from ww  w.  j a v a2 s. c  o  m*/

        ContainerInfo containerInfo;
        try {
            containerInfo = docker(settings).inspectContainer(containerName);
        } catch (ContainerNotFoundException e) {
            LOG.warn("The container " + containerName + " could not be found.");
            continue;
        }
        DateTime dateTimeCreated = new DateTime(containerInfo.created());

        if (clock.now().isAfter(dateTimeCreated.plus(period))) {
            unregisteredContainers.register(DockerContainer.fromContainerInfo(containerInfo));
        }
    }
    return unregisteredContainers;
}

From source file:cd.go.contrib.elasticagents.dockerswarm.elasticagent.DockerService.java

License:Apache License

public DockerService(String name, Date createdAt, Map<String, String> properties, String environment) {
    this.name = name;
    this.createdAt = new DateTime(createdAt);
    this.properties = properties;
    this.environment = environment;
}

From source file:cd.go.contrib.elasticagents.dockerswarm.elasticagent.DockerServices.java

License:Apache License

private DockerServices unregisteredAfterTimeout(PluginSettings settings, Agents knownAgents) throws Exception {
    Period period = settings.getAutoRegisterPeriod();
    DockerServices unregisteredContainers = new DockerServices();

    for (String serviceName : services.keySet()) {
        if (knownAgents.containsServiceWithId(serviceName)) {
            continue;
        }//from  ww w . j av  a2s .c  o  m

        Service serviceInfo;
        try {
            serviceInfo = docker(settings).inspectService(serviceName);
        } catch (ServiceNotFoundException e) {
            LOG.warn("The container " + serviceName + " could not be found.");
            continue;
        }
        DateTime dateTimeCreated = new DateTime(serviceInfo.createdAt());

        if (clock.now().isAfter(dateTimeCreated.plus(period))) {
            unregisteredContainers.register(DockerService.fromService(serviceInfo));
        }
    }
    return unregisteredContainers;
}

From source file:cd.go.contrib.elasticagents.marathon.MarathonAgentInstances.java

License:Apache License

private MarathonAgentInstances unregisteredAfterTimeout(PluginSettings settings, Agents knownAgents)
        throws Exception {
    MarathonAgentInstances unregisteredContainers = new MarathonAgentInstances();
    if (settings == null) {
        return unregisteredContainers;
    }/*from   w w w . java  2s  . c  o m*/
    Period period = settings.getAutoRegisterPeriod();

    for (MarathonInstance instance : instances.values()) {
        if (knownAgents.containsAgentWithId(instance.name())) {
            continue;
        }

        DateTime dateTimeCreated = new DateTime(instance.createdAt());

        if (clock.now().isAfter(dateTimeCreated.plus(period))) {
            unregisteredContainers.register(instance);
        }
    }
    return unregisteredContainers;
}