本文整理匯總了Java中org.joda.time.MutableDateTime.setMillisOfSecond方法的典型用法代碼示例。如果您正苦於以下問題:Java MutableDateTime.setMillisOfSecond方法的具體用法?Java MutableDateTime.setMillisOfSecond怎麽用?Java MutableDateTime.setMillisOfSecond使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.MutableDateTime
的用法示例。
在下文中一共展示了MutableDateTime.setMillisOfSecond方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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);
}
}
示例4: 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);
}
示例5: nextTimeAfter
import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
@CoverageIgnore
public DateTime nextTimeAfter(DateTime afterTime, DateTime dateTimeBarrier) {
MutableDateTime nextTime = new MutableDateTime(afterTime);
nextTime.setMillisOfSecond(0);
nextTime.secondOfDay().add(1);
while (true) { // day of week
while (true) { // month
while (true) { // day of month
while (true) { // hour
while (true) { // minute
while (true) { // second
if (secondField.matches(nextTime.getSecondOfMinute())) {
break;
}
nextTime.secondOfDay().add(1);
}
if (minuteField.matches(nextTime.getMinuteOfHour())) {
break;
}
nextTime.minuteOfDay().add(1);
nextTime.secondOfMinute().set(0);
}
if (hourField.matches(nextTime.getHourOfDay())) {
break;
}
nextTime.hourOfDay().add(1);
nextTime.minuteOfHour().set(0);
nextTime.secondOfMinute().set(0);
}
if (dayOfMonthField.matches(new LocalDate(nextTime))) {
break;
}
nextTime.addDays(1);
nextTime.setTime(0, 0, 0, 0);
checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
}
if (monthField.matches(nextTime.getMonthOfYear())) {
break;
}
nextTime.addMonths(1);
nextTime.setDayOfMonth(1);
nextTime.setTime(0, 0, 0, 0);
checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
}
if (dayOfWeekField.matches(new LocalDate(nextTime))) {
break;
}
nextTime.addDays(1);
nextTime.setTime(0, 0, 0, 0);
checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
}
return nextTime.toDateTime();
}
示例6: nextTimeAfter
import org.joda.time.MutableDateTime; //導入方法依賴的package包/類
public DateTime nextTimeAfter(DateTime afterTime, DateTime dateTimeBarrier) {
MutableDateTime nextTime = new MutableDateTime(afterTime);
nextTime.setMillisOfSecond(0);
nextTime.secondOfDay().add(1);
while (true) { // day of week
while (true) { // month
while (true) { // day of month
while (true) { // hour
while (true) { // minute
while (true) { // second
if (secondField.matches(nextTime.getSecondOfMinute())) {
break;
}
nextTime.secondOfDay().add(1);
}
if (minuteField.matches(nextTime.getMinuteOfHour())) {
break;
}
nextTime.minuteOfDay().add(1);
nextTime.secondOfMinute().set(0);
}
if (hourField.matches(nextTime.getHourOfDay())) {
break;
}
nextTime.hourOfDay().add(1);
nextTime.minuteOfHour().set(0);
nextTime.secondOfMinute().set(0);
}
if (dayOfMonthField.matches(new LocalDate(nextTime))) {
break;
}
nextTime.addDays(1);
nextTime.setTime(0, 0, 0, 0);
checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
}
if (monthField.matches(nextTime.getMonthOfYear())) {
break;
}
nextTime.addMonths(1);
nextTime.setDayOfMonth(1);
nextTime.setTime(0, 0, 0, 0);
checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
}
if (dayOfWeekField.matches(new LocalDate(nextTime))) {
break;
}
nextTime.addDays(1);
nextTime.setTime(0, 0, 0, 0);
checkIfDateTimeBarrierIsReached(nextTime, dateTimeBarrier);
}
return nextTime.toDateTime();
}
示例7: 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;
}
示例8: 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;
}
示例9: 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())));
}