List of usage examples for org.joda.time LocalDateTime millisOfDay
public Property millisOfDay()
From source file:ch.piratenpartei.pivote.serialize.DataOutput.java
License:Apache License
public void writeDateTime(LocalDateTime value) throws IOException { buffer.rewind();//from w w w .j a v a 2 s. c o m long millis = Days.daysBetween(DataIO.BASE_DATETIME, value).getDays() * DataIO.DAY_MILLIS; millis += value.millisOfDay().get(); buffer.putLong(DataIO.millisToNano100(millis)); writebuf(8); }
From source file:energy.usef.dso.workflow.step.DsoDetermineOrangeReductionPeriodsStub.java
License:Apache License
private List<ConnectionCapacityLimitationPeriodDto> buildPeriods( List<ConnectionMeterEventDto> connectionMeterEventDtos) { List<ConnectionCapacityLimitationPeriodDto> results = new ArrayList<>(); ConnectionCapacityLimitationPeriodDto connectionMeterEventPeriodDto = null; for (ConnectionMeterEventDto connectionMeterEventDto : connectionMeterEventDtos) { // if start/ending event, set endTime of previous period. if (connectionMeterEventPeriodDto != null && (MeterEventTypeDto.CONNECTION_RESUMPTION .equals(connectionMeterEventDto.getEventType()) || MeterEventTypeDto.CONNECTION_INTERRUPTION.equals(connectionMeterEventDto.getEventType()))) { connectionMeterEventPeriodDto.setEndDateTime(connectionMeterEventDto.getEventDateTime()); connectionMeterEventPeriodDto = null; }/* ww w . java2s.c o m*/ // if capacity management event, then set start time and end time if (MeterEventTypeDto.CAPACITY_MANAGEMENT.equals(connectionMeterEventDto.getEventType())) { LocalDateTime eventTime = connectionMeterEventDto.getEventDateTime(); BigInteger eventData = connectionMeterEventDto.getEventData(); if (eventData != null) { connectionMeterEventPeriodDto = new ConnectionCapacityLimitationPeriodDto(); connectionMeterEventPeriodDto.setEntityAddress(connectionMeterEventDto.getEntityAddress()); connectionMeterEventPeriodDto.setStartDateTime(eventTime); LocalDateTime endOfDay = eventTime.withMillisOfDay(eventTime.millisOfDay().getMaximumValue()); connectionMeterEventPeriodDto.setEndDateTime(endOfDay); connectionMeterEventPeriodDto.setCapacityReduction(eventData); results.add(connectionMeterEventPeriodDto); } else if (connectionMeterEventPeriodDto != null) { connectionMeterEventPeriodDto.setEndDateTime(eventTime); connectionMeterEventPeriodDto = null; } } } return results; }
From source file:org.gnucash.android.model.Budget.java
License:Apache License
/** * Returns the timestamp of the start of current period of the budget * @return Start timestamp in milliseconds *//* w w w . jav a 2 s .c o m*/ public long getStartofCurrentPeriod() { LocalDateTime localDate = new LocalDateTime(); int interval = mRecurrence.getPeriodType().getMultiplier(); switch (mRecurrence.getPeriodType()) { case DAY: localDate = localDate.millisOfDay().withMinimumValue().plusDays(interval); break; case WEEK: localDate = localDate.dayOfWeek().withMinimumValue().minusDays(interval); break; case MONTH: localDate = localDate.dayOfMonth().withMinimumValue().minusMonths(interval); break; case YEAR: localDate = localDate.dayOfYear().withMinimumValue().minusYears(interval); break; } return localDate.toDate().getTime(); }
From source file:org.gnucash.android.model.Budget.java
License:Apache License
/** * Returns the end timestamp of the current period * @return End timestamp in milliseconds *///w w w . j a v a2s . co m public long getEndOfCurrentPeriod() { LocalDateTime localDate = new LocalDateTime(); int interval = mRecurrence.getPeriodType().getMultiplier(); switch (mRecurrence.getPeriodType()) { case DAY: localDate = localDate.millisOfDay().withMaximumValue().plusDays(interval); break; case WEEK: localDate = localDate.dayOfWeek().withMaximumValue().plusWeeks(interval); break; case MONTH: localDate = localDate.dayOfMonth().withMaximumValue().plusMonths(interval); break; case YEAR: localDate = localDate.dayOfYear().withMaximumValue().plusYears(interval); break; } return localDate.toDate().getTime(); }
From source file:org.gnucash.android.model.Budget.java
License:Apache License
public long getStartOfPeriod(int periodNum) { LocalDateTime localDate = new LocalDateTime(mRecurrence.getPeriodStart().getTime()); int interval = mRecurrence.getPeriodType().getMultiplier() * periodNum; switch (mRecurrence.getPeriodType()) { case DAY://from w w w . j a v a 2 s .c o m localDate = localDate.millisOfDay().withMinimumValue().plusDays(interval); break; case WEEK: localDate = localDate.dayOfWeek().withMinimumValue().minusDays(interval); break; case MONTH: localDate = localDate.dayOfMonth().withMinimumValue().minusMonths(interval); break; case YEAR: localDate = localDate.dayOfYear().withMinimumValue().minusYears(interval); break; } return localDate.toDate().getTime(); }
From source file:org.gnucash.android.model.Budget.java
License:Apache License
/** * Returns the end timestamp of the period * @param periodNum Number of the period * @return End timestamp in milliseconds of the period *///from w w w . j a v a2 s. c o m public long getEndOfPeriod(int periodNum) { LocalDateTime localDate = new LocalDateTime(); int interval = mRecurrence.getPeriodType().getMultiplier() * periodNum; switch (mRecurrence.getPeriodType()) { case DAY: localDate = localDate.millisOfDay().withMaximumValue().plusDays(interval); break; case WEEK: localDate = localDate.dayOfWeek().withMaximumValue().plusWeeks(interval); break; case MONTH: localDate = localDate.dayOfMonth().withMaximumValue().plusMonths(interval); break; case YEAR: localDate = localDate.dayOfYear().withMaximumValue().plusYears(interval); break; } return localDate.toDate().getTime(); }