Example usage for org.joda.time DateTimeFieldType hourOfDay

List of usage examples for org.joda.time DateTimeFieldType hourOfDay

Introduction

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

Prototype

public static DateTimeFieldType hourOfDay() 

Source Link

Document

Get the hour of day (0-23) field type.

Usage

From source file:com.google.code.tickconverter.convert.ConvertAdapter.java

License:Open Source License

/**
 * This method is the main method of the convert process. While the {@link BlockingQueue} of {@link IDukascopyRO}
 * have for 10 seconds no objects in the {@link BlockingQueue} add this method this object into the
 * {@link MetatraderConverter}. If an {@link InvalidTimeException} will threw the converter put a new
 * {@link MetatraderBean} into the {@link BlockingQueue} of {@link IMetatraderRO} and get the information of the
 * values from the {@link MetatraderConverter} object.
 * //w w  w. ja  va  2 s  .c  om
 * @throws InterruptedException will threw if {@link Thread#interrupt()} is called in the poll phase
 * @throws InvalidTimeException will threw if {@link MetatraderConverter#incrementInterval()} have a low range for
 *             the new object after the creation of a new {@link MetatraderBean}
 */
public void convertProcess() throws InterruptedException {
    while (true) {
        IDukascopyRO object = dukaQueue.poll(2, TimeUnit.SECONDS);
        LoggerUtils.createDebugLog("poll object: " + object);
        if (null == object) {
            if (null != converter && converter.hasElements()) {
                putMetatraderObject();
            }

            break;
        }

        if (null == converter) {
            DateTime timestamp = object.getTimeStamp();
            DateTime start = new DateTime(timestamp.get(DateTimeFieldType.year()),
                    timestamp.get(DateTimeFieldType.monthOfYear()),
                    timestamp.get(DateTimeFieldType.dayOfMonth()), timestamp.get(DateTimeFieldType.hourOfDay()),
                    timestamp.get(DateTimeFieldType.minuteOfHour()));
            converter = new MetatraderConverter(start, Period.minutes(1));
        }
        try {
            converter.addDukascopy(object);
        } catch (InvalidTimeException e) {
            putMetatraderObject();
            incrementWhileAdd(object);
        }
    }
}

From source file:de.avanux.smartapplianceenabler.appliance.TimeOfDay.java

License:Open Source License

public TimeOfDay(LocalDateTime dateTime) {
    hour = dateTime.get(DateTimeFieldType.hourOfDay());
    minute = dateTime.get(DateTimeFieldType.minuteOfHour());
    second = dateTime.get(DateTimeFieldType.secondOfMinute());
}

From source file:de.openali.odysseus.chart.ext.base.axisrenderer.provider.DateTimeAxisFieldProvider.java

License:Open Source License

@Override
public IDateTimeAxisField getDateTimeAxisField(final IDataRange<Number> range) {

    final long dr = range.getMax().longValue() - range.getMin().longValue();
    final long sec = 1000;
    final long min = 60 * sec;
    final long hour = 60 * min;
    final long day = 24 * hour;

    if (dr < 3 * sec)
        return new DateTimeAxisField(DateTimeFieldType.millisOfSecond(), "YYYY.dd.MM\nHH:mm:ss:SSS", //$NON-NLS-1$
                new int[] { 1, 10, 100, 500 }, new int[] {});
    else if (dr < 3 * min)
        return new DateTimeAxisField(DateTimeFieldType.secondOfMinute(), "YY.dd.MM\nHH:mm:ss", //$NON-NLS-1$
                new int[] { 1, 15, 30 }, new int[] {});
    else if (dr < 3 * hour)
        return new DateTimeAxisField(DateTimeFieldType.minuteOfHour(), "YY.dd.MM\nHH:mm:ss", //$NON-NLS-1$
                new int[] { 1, 15, 30 }, new int[] {});
    else if (dr < 3 * day)
        return new DateTimeAxisField(DateTimeFieldType.minuteOfDay(), "dd.MM\nHH:mm", new int[] { 1, 15, 30 }, //$NON-NLS-1$
                new int[] {});
    else if (dr < 7 * day)
        return new DateTimeAxisField(DateTimeFieldType.hourOfDay(), "dd.MM\nHH:mm", //$NON-NLS-1$
                new int[] { 1, 2, 4, 6, 8, 12 }, new int[] { 12 });
    else if (dr < 30 * day)
        return new DateTimeAxisField(DateTimeFieldType.dayOfMonth(), "YYYY.dd.MM\ndddd", //$NON-NLS-1$
                new int[] { 1, 2, 7, 14 }, new int[] { 7, 14, 28 });
    else//from   w ww  . j av  a2s  . c om
        return new DateTimeAxisField(DateTimeFieldType.monthOfYear(), "YYYY.dd.MM", new int[] { 1, 2, 3, 4, 6 }, //$NON-NLS-1$
                new int[] { 6 });
}

From source file:net.karlmartens.platform.datatable.DataTableCell.java

License:Apache License

private static JsonElement creasteJsonElement(Object o) {
    if (o == null)
        return JsonNull.INSTANCE;

    if (o instanceof String)
        return new JsonPrimitive((String) o);

    if (o instanceof Boolean)
        return new JsonPrimitive((Boolean) o);

    if (o instanceof Number)
        return new JsonPrimitive((Number) o);

    if (o instanceof BaseLocal) {
        final BaseLocal date = (BaseLocal) o;
        final JsonObject json = new JsonObject();
        json.add("year", createJsonElement(DateTimeFieldType.year(), date));
        json.add("month", createJsonElement(DateTimeFieldType.monthOfYear(), date));
        json.add("day", createJsonElement(DateTimeFieldType.dayOfMonth(), date));
        json.add("hour", createJsonElement(DateTimeFieldType.hourOfDay(), date));
        json.add("minute", createJsonElement(DateTimeFieldType.minuteOfHour(), date));
        json.add("second", createJsonElement(DateTimeFieldType.secondOfMinute(), date));
        json.add("millis", createJsonElement(DateTimeFieldType.millisOfSecond(), date));
        return json;
    }/*w w w  .  j a  va2  s  .c  o m*/

    throw new UnsupportedOperationException();
}

From source file:net.sourceforge.fenixedu.domain.Summary.java

License:Open Source License

private void fillSummaryWithInfo(MultiLanguageString title, MultiLanguageString summaryText,
        Integer studentsNumber, Boolean isExtraLesson, Professorship professorship, String teacherName,
        Teacher teacher, Shift shift, Lesson lesson, YearMonthDay day, Space room, Partial hour, ShiftType type,
        Boolean taught) {//w  w  w . ja v  a 2  s .c  o m

    setShift(shift);
    setSummaryDateYearMonthDay(day);
    setExecutionCourse(shift.getExecutionCourse());
    setTitle(title);
    setSummaryText(summaryText);
    setIsExtraLesson(isExtraLesson);

    checkSpecialParameters(isExtraLesson, professorship, teacherName, teacher, lesson, hour, type);
    checkIfInternalTeacherHasProfessorhipInExecutionCourse(teacher, shift.getExecutionCourse());
    checkIfSummaryDateIsValid(day, shift.getExecutionPeriod(), lesson, isExtraLesson);

    setStudentsNumber(studentsNumber);
    setProfessorship(professorship);
    setTeacherName(teacherName);
    setTeacher(teacher);
    setLastModifiedDateDateTime(new DateTime());
    setSummaryType(type);
    setTaught(taught);

    if (isExtraLesson) {
        super.setLessonInstance(null);
        setRoom(room);
        HourMinuteSecond hourMinuteSecond = new HourMinuteSecond(hour.get(DateTimeFieldType.hourOfDay()),
                hour.get(DateTimeFieldType.minuteOfHour()), 0);
        setSummaryHourHourMinuteSecond(hourMinuteSecond);
    } else {
        setRoom(lesson.getSala());
        setSummaryHourHourMinuteSecond(lesson.getBeginHourMinuteSecond());
        lessonInstanceManagement(lesson, day, lesson.getSala());
        if (getLessonInstance() == null) {
            throw new DomainException("error.Summary.empty.LessonInstances");
        }
    }
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.teacher.SummariesManagementDA.java

License:Open Source License

public ActionForward prepareEditSummary(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws FenixServiceException {

    Professorship teacherLogged = ((Professorship) request.getAttribute("loggedTeacherProfessorship"));
    DynaActionForm dynaActionForm = (DynaActionForm) form;
    Summary summary = getSummaryFromParameter(request);

    SummaryType summaryType;//from ww w  .j ava 2  s  .  c o m
    if (summary.isExtraSummary()) {
        summaryType = SummaryType.EXTRA_SUMMARY;
        request.setAttribute("notShowLessonPlanningsAndSummaries", Boolean.TRUE);
    } else {
        summaryType = SummaryType.NORMAL_SUMMARY;
    }

    DateTimeFieldType[] dateTimeFieldTypes = { DateTimeFieldType.hourOfDay(),
            DateTimeFieldType.minuteOfHour() };
    HourMinuteSecond time = summary.getSummaryHourHourMinuteSecond();
    int[] timeArray = { time.getHour(), time.getMinuteOfHour() };
    Partial timePartial = new Partial(dateTimeFieldTypes, timeArray);

    SummariesManagementBean bean = new SummariesManagementBean(summary.getTitle(), summary.getSummaryText(),
            summary.getStudentsNumber(), summaryType, summary.getProfessorship(), summary.getTeacherName(),
            summary.getTeacher(), summary.getShift(), summary.getLesson(), summary.getSummaryDateYearMonthDay(),
            summary.getRoom(), timePartial, summary, teacherLogged, summary.getSummaryType(),
            summary.getTaught());

    return goToSummaryManagementPageAgain(mapping, request, dynaActionForm, bean);
}

From source file:org.apache.wicket.extensions.yui.calendar.DateTimeField.java

License:Apache License

/**
 * @see org.apache.wicket.Component#onBeforeRender()
 *///from w  w w .ja va 2s .  com
@Override
protected void onBeforeRender() {
    dateField.setRequired(isRequired());
    hoursField.setRequired(isRequired());
    minutesField.setRequired(isRequired());

    boolean use12HourFormat = use12HourFormat();
    amOrPmChoice.setVisible(use12HourFormat);

    Date modelObject = (Date) getDefaultModelObject();
    if (modelObject == null) {
        date = null;
        hours = null;
        minutes = null;
    } else {
        // convert date to the client's time zone if we have that info
        TimeZone zone = getClientTimeZone();
        if (zone != null) {
            modelObject = changeTimeZone(modelObject, zone);
        }

        MutableDateTime mDate = new MutableDateTime(modelObject);

        date = mDate.toDate();

        if (use12HourFormat) {
            int hourOfHalfDay = mDate.get(DateTimeFieldType.hourOfHalfday());
            hours = hourOfHalfDay == 0 ? 12 : hourOfHalfDay;
        } else {
            hours = mDate.get(DateTimeFieldType.hourOfDay());
        }

        amOrPm = (mDate.get(DateTimeFieldType.halfdayOfDay()) == 0) ? AM_PM.AM : AM_PM.PM;
        minutes = mDate.getMinuteOfHour();
    }

    super.onBeforeRender();
}

From source file:org.codelibs.elasticsearch.common.joda.Joda.java

License:Apache License

public static FormatDateTimeFormatter getStrictStandardDateFormatter() {
    // 2014/10/10
    DateTimeFormatter shortFormatter = new DateTimeFormatterBuilder()
            .appendFixedDecimal(DateTimeFieldType.year(), 4).appendLiteral('/')
            .appendFixedDecimal(DateTimeFieldType.monthOfYear(), 2).appendLiteral('/')
            .appendFixedDecimal(DateTimeFieldType.dayOfMonth(), 2).toFormatter().withZoneUTC();

    // 2014/10/10 12:12:12
    DateTimeFormatter longFormatter = new DateTimeFormatterBuilder()
            .appendFixedDecimal(DateTimeFieldType.year(), 4).appendLiteral('/')
            .appendFixedDecimal(DateTimeFieldType.monthOfYear(), 2).appendLiteral('/')
            .appendFixedDecimal(DateTimeFieldType.dayOfMonth(), 2).appendLiteral(' ')
            .appendFixedSignedDecimal(DateTimeFieldType.hourOfDay(), 2).appendLiteral(':')
            .appendFixedSignedDecimal(DateTimeFieldType.minuteOfHour(), 2).appendLiteral(':')
            .appendFixedSignedDecimal(DateTimeFieldType.secondOfMinute(), 2).toFormatter().withZoneUTC();

    DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder()
            .append(longFormatter.withZone(DateTimeZone.UTC).getPrinter(), new DateTimeParser[] {
                    longFormatter.getParser(), shortFormatter.getParser(), new EpochTimeParser(true) });

    return new FormatDateTimeFormatter("yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis",
            builder.toFormatter().withZone(DateTimeZone.UTC), Locale.ROOT);
}

From source file:org.codelibs.elasticsearch.common.joda.StrictISODateTimeFormat.java

License:Apache License

/**
 * Adds the time fields to the builder./*w w  w.ja  v  a 2 s  .  com*/
 * Specification reference: 5.3.1.
 *
 * @param bld  the builder
 * @param fields  the fields
 * @param extended  whether to use the extended format
 * @param strictISO  whether to be strict
 * @param reducedPrec  whether the date was reduced precision
 * @param datePresent  whether there was a date
 * @since 1.1
 */
private static void time(DateTimeFormatterBuilder bld, Collection<DateTimeFieldType> fields, boolean extended,
        boolean strictISO, boolean reducedPrec, boolean datePresent) {

    boolean hour = fields.remove(DateTimeFieldType.hourOfDay());
    boolean minute = fields.remove(DateTimeFieldType.minuteOfHour());
    boolean second = fields.remove(DateTimeFieldType.secondOfMinute());
    boolean milli = fields.remove(DateTimeFieldType.millisOfSecond());
    if (!hour && !minute && !second && !milli) {
        return;
    }
    if (hour || minute || second || milli) {
        if (strictISO && reducedPrec) {
            throw new IllegalArgumentException(
                    "No valid ISO8601 format for fields because Date was reduced precision: " + fields);
        }
        if (datePresent) {
            bld.appendLiteral('T');
        }
    }
    if (hour && minute && second || (hour && !second && !milli)) {
        // OK - HMSm/HMS/HM/H - valid in combination with date
    } else {
        if (strictISO && datePresent) {
            throw new IllegalArgumentException(
                    "No valid ISO8601 format for fields because Time was truncated: " + fields);
        }
        if (!hour && (minute && second || (minute && !milli) || second)) {
            // OK - MSm/MS/M/Sm/S - valid ISO formats
        } else {
            if (strictISO) {
                throw new IllegalArgumentException("No valid ISO8601 format for fields: " + fields);
            }
        }
    }
    if (hour) {
        bld.appendHourOfDay(2);
    } else if (minute || second || milli) {
        bld.appendLiteral('-');
    }
    if (extended && hour && minute) {
        bld.appendLiteral(':');
    }
    if (minute) {
        bld.appendMinuteOfHour(2);
    } else if (second || milli) {
        bld.appendLiteral('-');
    }
    if (extended && minute && second) {
        bld.appendLiteral(':');
    }
    if (second) {
        bld.appendSecondOfMinute(2);
    } else if (milli) {
        bld.appendLiteral('-');
    }
    if (milli) {
        bld.appendLiteral('.');
        bld.appendMillisOfSecond(3);
    }
}

From source file:org.datavec.api.util.jackson.DateTimeFieldTypeDeserializer.java

License:Apache License

private static Map<String, DateTimeFieldType> getMap() {
    Map<String, DateTimeFieldType> ret = new HashMap<>();
    ret.put(DateTimeFieldType.centuryOfEra().getName(), DateTimeFieldType.centuryOfEra());
    ret.put(DateTimeFieldType.clockhourOfDay().getName(), DateTimeFieldType.clockhourOfDay());
    ret.put(DateTimeFieldType.clockhourOfHalfday().getName(), DateTimeFieldType.clockhourOfHalfday());
    ret.put(DateTimeFieldType.dayOfMonth().getName(), DateTimeFieldType.dayOfMonth());
    ret.put(DateTimeFieldType.dayOfWeek().getName(), DateTimeFieldType.dayOfWeek());
    ret.put(DateTimeFieldType.dayOfYear().getName(), DateTimeFieldType.dayOfYear());
    ret.put(DateTimeFieldType.era().getName(), DateTimeFieldType.era());
    ret.put(DateTimeFieldType.halfdayOfDay().getName(), DateTimeFieldType.halfdayOfDay());
    ret.put(DateTimeFieldType.hourOfDay().getName(), DateTimeFieldType.hourOfDay());
    ret.put(DateTimeFieldType.hourOfHalfday().getName(), DateTimeFieldType.hourOfHalfday());
    ret.put(DateTimeFieldType.millisOfDay().getName(), DateTimeFieldType.millisOfDay());
    ret.put(DateTimeFieldType.millisOfSecond().getName(), DateTimeFieldType.millisOfSecond());
    ret.put(DateTimeFieldType.minuteOfDay().getName(), DateTimeFieldType.minuteOfDay());
    ret.put(DateTimeFieldType.minuteOfHour().getName(), DateTimeFieldType.minuteOfHour());
    ret.put(DateTimeFieldType.secondOfDay().getName(), DateTimeFieldType.secondOfDay());
    ret.put(DateTimeFieldType.secondOfMinute().getName(), DateTimeFieldType.secondOfMinute());
    ret.put(DateTimeFieldType.weekOfWeekyear().getName(), DateTimeFieldType.weekOfWeekyear());
    ret.put(DateTimeFieldType.weekyear().getName(), DateTimeFieldType.weekyear());
    ret.put(DateTimeFieldType.weekyearOfCentury().getName(), DateTimeFieldType.weekyearOfCentury());
    ret.put(DateTimeFieldType.year().getName(), DateTimeFieldType.year());
    ret.put(DateTimeFieldType.yearOfCentury().getName(), DateTimeFieldType.yearOfCentury());
    ret.put(DateTimeFieldType.yearOfEra().getName(), DateTimeFieldType.yearOfEra());

    return ret;/*from www.ja v a  2s . c  om*/
}