Example usage for org.joda.time.base AbstractPartial get

List of usage examples for org.joda.time.base AbstractPartial get

Introduction

In this page you can find the example usage for org.joda.time.base AbstractPartial get.

Prototype

public int get(DateTimeFieldType type) 

Source Link

Document

Get the value of one of the fields of a datetime.

Usage

From source file:pt.ist.fenixWebFramework.rendererExtensions.MultipleFormatTimeInputRenderer.java

License:Open Source License

private Date convertPartialToDate(AbstractPartial partial) {
    if (partial == null) {
        return null;
    }/*from  w w w. jav  a  2s  .  c  o  m*/
    Calendar calendar = Calendar.getInstance();
    calendar.clear();
    if (isHour()) {
        calendar.set(Calendar.HOUR_OF_DAY, partial.get(DateTimeFieldType.hourOfDay()));
    }
    if (isMinute()) {
        calendar.set(Calendar.MINUTE, partial.get(DateTimeFieldType.minuteOfHour()));
    }
    return calendar.getTime();
}

From source file:pt.ist.fenixWebFramework.rendererExtensions.PartialInputRenderer.java

License:Open Source License

private Date convertPartialToDate(AbstractPartial partial) {
    if (partial == null) {
        return null;
    }// w w  w  .j ava2 s  .  c  o m

    Calendar calendar = Calendar.getInstance();
    calendar.clear();

    if (isDay()) {
        calendar.set(Calendar.DAY_OF_MONTH, partial.get(DateTimeFieldType.dayOfMonth()));
    }

    if (isMonth()) {
        calendar.set(Calendar.MONTH, partial.get(DateTimeFieldType.monthOfYear()) - 1);
    }

    if (isYear()) {
        calendar.set(Calendar.YEAR, partial.get(DateTimeFieldType.year()));
    }

    if (isHour()) {
        calendar.set(Calendar.HOUR_OF_DAY, partial.get(DateTimeFieldType.hourOfDay()));
    }

    if (isMinute()) {
        calendar.set(Calendar.MINUTE, partial.get(DateTimeFieldType.minuteOfHour()));
    }

    if (isSecond()) {
        calendar.set(Calendar.SECOND, partial.get(DateTimeFieldType.secondOfMinute()));
    }

    return calendar.getTime();
}

From source file:pt.ist.fenixWebFramework.rendererExtensions.PartialRenderer.java

License:Open Source License

private Calendar convertPartialToCalendar(AbstractPartial partial) {
    Calendar calendar = Calendar.getInstance();
    calendar.clear();/*  w  w  w.j a v a  2  s.  c  o  m*/

    DateTimeFieldType[] fieldTypes = partial.getFieldTypes();
    for (DateTimeFieldType fieldType : fieldTypes) {
        if (fieldType.equals(DateTimeFieldType.dayOfMonth())) {
            calendar.set(Calendar.DAY_OF_MONTH, partial.get(DateTimeFieldType.dayOfMonth()));
            continue;
        }

        if (fieldType.equals(DateTimeFieldType.monthOfYear())) {
            calendar.set(Calendar.MONTH, partial.get(DateTimeFieldType.monthOfYear()) - 1);
            continue;
        }

        if (fieldType.equals(DateTimeFieldType.year())) {
            calendar.set(Calendar.YEAR, partial.get(DateTimeFieldType.year()));
            continue;
        }

        if (fieldType.equals(DateTimeFieldType.hourOfDay())) {
            calendar.set(Calendar.HOUR_OF_DAY, partial.get(DateTimeFieldType.hourOfDay()));
            continue;
        }

        if (fieldType.equals(DateTimeFieldType.minuteOfHour())) {
            calendar.set(Calendar.MINUTE, partial.get(DateTimeFieldType.minuteOfHour()));
            continue;
        }

        if (fieldType.equals(DateTimeFieldType.secondOfMinute())) {
            calendar.set(Calendar.SECOND, partial.get(DateTimeFieldType.secondOfMinute()));
            continue;
        }
    }

    return calendar;
}