當前位置: 首頁>>代碼示例>>Java>>正文


Java MutableDateTime.setMinuteOfHour方法代碼示例

本文整理匯總了Java中org.joda.time.MutableDateTime.setMinuteOfHour方法的典型用法代碼示例。如果您正苦於以下問題:Java MutableDateTime.setMinuteOfHour方法的具體用法?Java MutableDateTime.setMinuteOfHour怎麽用?Java MutableDateTime.setMinuteOfHour使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.MutableDateTime的用法示例。


在下文中一共展示了MutableDateTime.setMinuteOfHour方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setDateTime

import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
/**
 * Sets the correct part of a {@link DateTime} corresponding to a
 * {@link SqlDatePartFunction}.
 *
 * @param value  The value to be set for the dateTime with the sqlDatePartFn
 * @param sqlDatePartFn  The function used to extract part of a date with sql.
 * @param dateTime  The original dateTime to create a copy of.
 */
protected void setDateTime(int value, SqlDatePartFunction sqlDatePartFn, MutableDateTime dateTime) {
    if (YEAR.equals(sqlDatePartFn)) {
        dateTime.setYear(value);
    } else if (MONTH.equals(sqlDatePartFn)) {
        dateTime.setMonthOfYear(value);
    } else if (WEEK.equals(sqlDatePartFn)) {
        dateTime.setWeekOfWeekyear(value);
        dateTime.setDayOfWeek(1);
    } else if (DAYOFYEAR.equals(sqlDatePartFn)) {
        dateTime.setDayOfYear(value);
    } else if (HOUR.equals(sqlDatePartFn)) {
        dateTime.setHourOfDay(value);
    } else if (MINUTE.equals(sqlDatePartFn)) {
        dateTime.setMinuteOfHour(value);
    } else if (SECOND.equals(sqlDatePartFn)) {
        dateTime.setSecondOfMinute(value);
    } else {
        throw new IllegalArgumentException("Can't set value " + value + " for " + sqlDatePartFn);
    }
}
 
開發者ID:yahoo,項目名稱:fili,代碼行數:29,代碼來源:SqlTimeConverter.java

示例2: getDateTimeBegin

import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
public DateTime getDateTimeBegin() {
    if (mDateTimeBegin == null) {
        MutableDateTime begin = new MutableDateTime(getDate());
        int hour = 0;
        boolean excepted = true;
        while (excepted) {
            try {
                begin.setHourOfDay(hour);
                begin.setMinuteOfHour(0);
                begin.setSecondOfMinute(0);
                begin.setMillisOfSecond(0);
                hour++;
                excepted = false;
            } catch (Exception e) {

            }
        }
        mDateTimeBegin = begin.toDateTime();
    }
    return mDateTimeBegin;
}
 
開發者ID:codlab,項目名稱:misfit-analyser,代碼行數:22,代碼來源:DailyActivity.java

示例3: getDateTimeEnd

import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
public DateTime getDateTimeEnd() {
    if (mDateTimeEnd == null) {
        MutableDateTime end = new MutableDateTime(getDate());
        int hour = 23;
        boolean excepted = true;
        while (excepted) {
            try {
                end.setHourOfDay(hour);
                end.setMinuteOfHour(59);
                end.setSecondOfMinute(59);
                end.setMillisOfSecond(999);
                hour--;
                excepted = false;
            } catch (Exception e) {

            }
        }
        mDateTimeEnd = end.toDateTime();
    }
    return mDateTimeEnd;
}
 
開發者ID:codlab,項目名稱:misfit-analyser,代碼行數:22,代碼來源:DailyActivity.java

示例4: convertToAvro

import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
@Override
public Object convertToAvro(XMLGregorianCalendar xts) {
    if (xts == null) {
        return null;
    }

    MutableDateTime dateTime = new MutableDateTime();
    try {
        dateTime.setYear(xts.getYear());
        dateTime.setMonthOfYear(xts.getMonth());
        dateTime.setDayOfMonth(xts.getDay());
        dateTime.setHourOfDay(xts.getHour());
        dateTime.setMinuteOfHour(xts.getMinute());
        dateTime.setSecondOfMinute(xts.getSecond());
        dateTime.setMillisOfSecond(xts.getMillisecond());

        DateTimeZone tz = DateTimeZone.forOffsetMillis(xts.getTimezone() * 60000);
        if (tz != null) {
            dateTime.setZoneRetainFields(tz);
        }

        return Long.valueOf(dateTime.getMillis());
    } catch (IllegalArgumentException e) {
        throw new ComponentException(e);
    }
}
 
開發者ID:Talend,項目名稱:components,代碼行數:27,代碼來源:XMLGregorianCalendarToDateTimeConverter.java

示例5: asTimeOnly

import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
/**
 * Get the value as a time only.
 *
 * @param t a time only
 * @throws FIXValueFormatException if the value is not a time only
 */
public void asTimeOnly(MutableDateTime t) {
    if (length != 8 && length != 12)
        throw new FIXValueFormatException("Not a time only");

    t.setHourOfDay(getDigits(2, offset + 0));
    t.setMinuteOfHour(getDigits(2, offset + 3));
    t.setSecondOfMinute(getDigits(2, offset + 6));
    t.setMillisOfSecond(length == 12 ? getDigits(3, offset + 9) : 0);
}
 
開發者ID:paritytrading,項目名稱:philadelphia,代碼行數:16,代碼來源:FIXValue.java

示例6: getTimeAfter

import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
public DateTime getTimeAfter(DateTime dateTime) {
    try {
        String[] fixedCronExp = appendYearField(expression.split("\\s+"));
        validate(fixedCronExp);

        MutableDateTime mdt = dateTime.toMutableDateTime();
        mdt.setMillisOfSecond(0);

        List<Integer> secondValues = parse(secondParsers, fixedCronExp[AbstractParser.DurationField.SECOND.getIndex()], dateTime, AbstractParser.DurationField.SECOND);
        List<Integer> minuteValues = parse(minuteParsers, fixedCronExp[AbstractParser.DurationField.MINUTE.getIndex()], dateTime, AbstractParser.DurationField.MINUTE);
        List<Integer> hourValues = parse(hourParsers, fixedCronExp[AbstractParser.DurationField.HOUR.getIndex()], dateTime, AbstractParser.DurationField.HOUR);
        List<Integer> monthValues = parse(monthParsers, fixedCronExp[AbstractParser.DurationField.MONTH.getIndex()], dateTime, AbstractParser.DurationField.MONTH);
        List<Integer> yearValues = parse(yearParsers, fixedCronExp[AbstractParser.DurationField.YEAR.getIndex()], dateTime, AbstractParser.DurationField.YEAR);

        int yearStartIndex = searchNotLessThanIndex(yearValues, mdt.getYear());
        for (int yearIndex = yearStartIndex, yearLen = yearValues.size(); yearIndex < yearLen; yearIndex++) {
            int year = yearValues.get(yearIndex);
            mdt.setYear(year);
            int monthStartIndex = (year == dateTime.getYear()) ? searchNotLessThanIndex(monthValues, dateTime.getMonthOfYear()) : 0;

            for (int monthIndex = monthStartIndex, monthLen = monthValues.size(); monthIndex < monthLen; monthIndex++) {
                int month = monthValues.get(monthIndex);
                mdt.setMonthOfYear(month);
                List<Integer> dayValues = parseDayValueList(fixedCronExp, mdt.toDateTime());
                int dayStartIndex = (year == dateTime.getYear() && month == dateTime.getMonthOfYear())
                        ? searchNotLessThanIndex(dayValues, dateTime.getDayOfMonth()) : 0;

                int maxDayOfMonth = mdt.toDateTime().dayOfMonth().withMaximumValue().toLocalDate().getDayOfMonth();
                for (int dayIndex = dayStartIndex, dayLen = dayValues.size(); dayIndex < dayLen; dayIndex++) {
                    int day = dayValues.get(dayIndex);
                    if (day > maxDayOfMonth) {
                        break;
                    }
                    mdt.setDayOfMonth(day);
                    int hourStartIndex = (year == dateTime.getYear() && month == dateTime.getMonthOfYear() && day == dateTime.getDayOfMonth())
                            ? searchNotLessThanIndex(hourValues, dateTime.getHourOfDay()) : 0;

                    for (int hourIndex = hourStartIndex, hourLen = hourValues.size(); hourIndex < hourLen; hourIndex++) {
                        int hour = hourValues.get(hourIndex);
                        mdt.setHourOfDay(hour);
                        int minuteStartIndex = (year == dateTime.getYear() && month == dateTime.getMonthOfYear()
                                && day == dateTime.getDayOfMonth() && hour == dateTime.getHourOfDay())
                                ? searchNotLessThanIndex(minuteValues, dateTime.getMinuteOfHour()) : 0;

                        for (int minuteIndex = minuteStartIndex, minuteLen = minuteValues.size(); minuteIndex < minuteLen; minuteIndex++) {
                            int minute = minuteValues.get(minuteIndex);
                            int secondStartIndex = (year == dateTime.getYear() && month == dateTime.getMonthOfYear()
                                    && day == dateTime.getDayOfMonth() && hour == dateTime.getHourOfDay() && minute == dateTime.getMinuteOfHour())
                                    ? searchNotLessThanIndex(secondValues, dateTime.getSecondOfMinute()) : 0;
                            mdt.setMinuteOfHour(minute);
                            for (int secondIndex = secondStartIndex, secondLen = secondValues.size(); secondIndex < secondLen; secondIndex++) {
                                int second = secondValues.get(secondIndex);
                                mdt.setSecondOfMinute(second);
                                if (mdt.isAfter(dateTime)) {
                                    return mdt.toDateTime();
                                }
                            }
                        }
                    }
                }
            }
        }
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }
    return null;
}
 
開發者ID:stuxuhai,項目名稱:jcron,代碼行數:68,代碼來源:CronExpression.java

示例7: getTimeBefore

import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
public DateTime getTimeBefore(DateTime dateTime) {
    try {
        String[] fixedCronExp = appendYearField(expression.split("\\s+"));
        validate(fixedCronExp);

        MutableDateTime mdt = dateTime.toMutableDateTime();
        mdt.setMillisOfSecond(0);

        List<Integer> secondValues = parse(secondParsers, fixedCronExp[AbstractParser.DurationField.SECOND.getIndex()], dateTime, AbstractParser.DurationField.SECOND);
        List<Integer> minuteValues = parse(minuteParsers, fixedCronExp[AbstractParser.DurationField.MINUTE.getIndex()], dateTime, AbstractParser.DurationField.MINUTE);
        List<Integer> hourValues = parse(hourParsers, fixedCronExp[AbstractParser.DurationField.HOUR.getIndex()], dateTime, AbstractParser.DurationField.HOUR);
        List<Integer> monthValues = parse(monthParsers, fixedCronExp[AbstractParser.DurationField.MONTH.getIndex()], dateTime, AbstractParser.DurationField.MONTH);
        List<Integer> yearValues = parse(yearParsers, fixedCronExp[AbstractParser.DurationField.YEAR.getIndex()], dateTime, AbstractParser.DurationField.YEAR);

        int yearStartIndex = searchNotGreaterThanIndex(yearValues, mdt.getYear());
        for (int yearIndex = yearStartIndex; yearIndex >= 0; yearIndex--) {
            int year = yearValues.get(yearIndex);
            mdt.setYear(year);
            int monthStartIndex = (year == dateTime.getYear()) ? searchNotGreaterThanIndex(monthValues, dateTime.getMonthOfYear())
                    : monthValues.size() - 1;

            for (int monthIndex = monthStartIndex; monthIndex >= 0; monthIndex--) {
                int month = monthValues.get(monthIndex);
                mdt.setMonthOfYear(month);
                List<Integer> dayValues = parseDayValueList(fixedCronExp, mdt.toDateTime());
                int dayStartIndex = (year == dateTime.getYear() && month == dateTime.getMonthOfYear())
                        ? searchNotGreaterThanIndex(dayValues, dateTime.getDayOfMonth()) : dayValues.size() - 1;

                int maxDayOfMonth = mdt.toDateTime().dayOfMonth().withMaximumValue().toLocalDate().getDayOfMonth();
                for (int dayIndex = dayStartIndex; dayIndex >= 0; dayIndex--) {
                    int day = dayValues.get(dayIndex);
                    if (day > maxDayOfMonth) {
                        break;
                    }
                    mdt.setDayOfMonth(day);
                    int hourStartIndex = (year == dateTime.getYear() && month == dateTime.getMonthOfYear() && day == dateTime.getDayOfMonth())
                            ? searchNotGreaterThanIndex(hourValues, dateTime.getHourOfDay()) : hourValues.size() - 1;

                    for (int hourIndex = hourStartIndex; hourIndex >= 0; hourIndex--) {
                        int hour = hourValues.get(hourIndex);
                        mdt.setHourOfDay(hour);
                        int minuteStartIndex = (year == dateTime.getYear() && month == dateTime.getMonthOfYear()
                                && day == dateTime.getDayOfMonth() && hour == dateTime.getHourOfDay())
                                ? searchNotGreaterThanIndex(minuteValues, dateTime.getMinuteOfHour()) : minuteValues.size() - 1;

                        for (int minuteIndex = minuteStartIndex; minuteIndex >= 0; minuteIndex--) {
                            int minute = minuteValues.get(minuteIndex);
                            mdt.setMinuteOfHour(minute);
                            int secondStartIndex = (year == dateTime.getYear() && month == dateTime.getMonthOfYear()
                                    && day == dateTime.getDayOfMonth() && hour == dateTime.getHourOfDay() && minute == dateTime.getMinuteOfHour())
                                    ? searchNotGreaterThanIndex(secondValues, dateTime.getSecondOfMinute()) : secondValues.size() - 1;

                            for (int secondIndex = secondStartIndex; secondIndex >= 0; secondIndex--) {
                                int second = secondValues.get(secondIndex);
                                mdt.setSecondOfMinute(second);
                                if (mdt.isBefore(dateTime)) {
                                    return mdt.toDateTime();
                                }
                            }
                        }
                    }
                }
            }
        }
    } catch (ParseException e) {
        throw new RuntimeException(e);
    }

    return null;
}
 
開發者ID:stuxuhai,項目名稱:jcron,代碼行數:71,代碼來源:CronExpression.java

示例8: testSearchDateField

import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
@Test
public void testSearchDateField() throws Exception {
    DateTimeFormatter dateFormatter = DateTimeFormat.forPattern("yyyy-MM-dd");
    DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
    DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("HH:mm:ss");

    Instant now = Instant.now();
    String currentDateFormatted = dateFormatter.print(now.getMillis());

    SearchQuery s1 = clientService.newSearch();
    s1.target("Check");
    s1.condition(new SearchCondition("TranDate", "Date.onOrAfter", Arrays.asList("2017-01-01 12:00:00")));
    s1.condition(new SearchCondition("CustomDateField1", "Date.onOrAfter", Arrays.asList("14:00:00")));

    SearchRecord sr1 = (SearchRecord) s1.toNativeQuery();
    assertNotNull(sr1);
    Assert.assertEquals(TransactionSearch.class, sr1.getClass());

    TransactionSearch search = (TransactionSearch) sr1;
    assertNotNull(search.getBasic());

    TransactionSearchBasic searchBasic = search.getBasic();
    assertNotNull(searchBasic.getTranDate());

    SearchDateField field1 = searchBasic.getTranDate();
    Assert.assertEquals(SearchDateFieldOperator.ON_OR_AFTER, field1.getOperator());
    assertNotNull(field1.getSearchValue());
    assertNull(field1.getSearchValue2());
    assertEquals("2017-01-01 12:00:00",
            dateTimeFormatter.print((Long) calendarValueConverter.convertToAvro(field1.getSearchValue())));

    SearchCustomFieldList customFieldList = searchBasic.getCustomFieldList();
    assertNotNull(customFieldList);
    assertNotNull(customFieldList.getCustomField());
    Assert.assertEquals(1, customFieldList.getCustomField().size());

    MutableDateTime controlDateTime = new MutableDateTime();
    controlDateTime.setHourOfDay(14);
    controlDateTime.setMinuteOfHour(0);
    controlDateTime.setSecondOfMinute(0);
    controlDateTime.setMillisOfSecond(0);
    String controlTimeFormatted = timeFormatter.print(controlDateTime);

    SearchDateCustomField customField1 = (SearchDateCustomField) customFieldList.getCustomField().get(0);
    Assert.assertEquals(SearchDateFieldOperator.ON_OR_AFTER, customField1.getOperator());
    assertNotNull(customField1.getSearchValue());
    assertNull(customField1.getSearchValue2());
    assertEquals(currentDateFormatted + " " + controlTimeFormatted,
            dateTimeFormatter.print((Long) calendarValueConverter.convertToAvro(customField1.getSearchValue())));
}
 
開發者ID:Talend,項目名稱:components,代碼行數:51,代碼來源:SearchQueryTest.java


注:本文中的org.joda.time.MutableDateTime.setMinuteOfHour方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。