Search in sources :

Example 31 with DateTime

use of org.joda.time.DateTime in project killbill by killbill.

the class DefaultSubscriptionBaseApiService method validateEffectiveDate.

private void validateEffectiveDate(final SubscriptionBase subscription, final ReadableInstant effectiveDate) throws SubscriptionBaseApiException {
    final SubscriptionBaseTransition previousTransition = subscription.getPreviousTransition();
    // Our effectiveDate must be after or equal the last transition that already occured (START, PHASE1, PHASE2,...) or the startDate for future started subscription
    final DateTime earliestValidDate = previousTransition != null ? previousTransition.getEffectiveTransitionTime() : subscription.getStartDate();
    if (effectiveDate.isBefore(earliestValidDate)) {
        throw new SubscriptionBaseApiException(ErrorCode.SUB_INVALID_REQUESTED_DATE, effectiveDate.toString(), previousTransition != null ? previousTransition.getEffectiveTransitionTime() : "null");
    }
}
Also used : DateTime(org.joda.time.DateTime)

Example 32 with DateTime

use of org.joda.time.DateTime in project killbill by killbill.

the class InternalCallContextFactory method createInternalCallContext.

// Used when we need to re-hydrate the callcontext with the account_record_id (when creating the account)
public InternalCallContext createInternalCallContext(final Long accountRecordId, final InternalCallContext context) {
    final DateTimeZone fixedOffsetTimeZone = getFixedOffsetTimeZone(accountRecordId, context.getTenantRecordId());
    final DateTime referenceTime = getReferenceTime(accountRecordId, context.getTenantRecordId());
    populateMDCContext(accountRecordId, context.getTenantRecordId());
    return new InternalCallContext(context, accountRecordId, fixedOffsetTimeZone, referenceTime, clock.getUTCNow());
}
Also used : InternalCallContext(org.killbill.billing.callcontext.InternalCallContext) DateTimeZone(org.joda.time.DateTimeZone) DateTime(org.joda.time.DateTime)

Example 33 with DateTime

use of org.joda.time.DateTime in project killbill by killbill.

the class AuditLogModelDaoMapper method map.

@Override
public AuditLogModelDao map(final int index, final ResultSet r, final StatementContext ctx) throws SQLException {
    final UUID id = getUUID(r, "id");
    final String tableName = r.getString("table_name");
    final long targetRecordId = r.getLong("target_record_id");
    final String changeType = r.getString("change_type");
    final DateTime createdDate = getDateTime(r, "created_date");
    final String createdBy = r.getString("created_by");
    final String reasonCode = r.getString("reason_code");
    final String comments = r.getString("comments");
    final UUID userToken = getUUID(r, "user_token");
    final EntityAudit entityAudit = new EntityAudit(id, TableName.valueOf(tableName), targetRecordId, ChangeType.valueOf(changeType), createdDate);
    // TODO - we have the tenant_record_id but not the tenant id here
    final CallContext callContext = new DefaultCallContext(null, createdBy, createdDate, reasonCode, comments, userToken);
    return new AuditLogModelDao(entityAudit, callContext);
}
Also used : DefaultCallContext(org.killbill.billing.callcontext.DefaultCallContext) AuditLogModelDao(org.killbill.billing.util.audit.dao.AuditLogModelDao) UUID(java.util.UUID) CallContext(org.killbill.billing.util.callcontext.CallContext) DefaultCallContext(org.killbill.billing.callcontext.DefaultCallContext) DateTime(org.joda.time.DateTime)

Example 34 with DateTime

use of org.joda.time.DateTime in project killbill by killbill.

the class AccountDateTimeUtils method getFixedOffsetTimeZone.

public static DateTimeZone getFixedOffsetTimeZone(final Account account) {
    final DateTimeZone referenceDateTimeZone = account.getTimeZone();
    final DateTime referenceDateTime = getReferenceDateTime(account);
    // Check if DST was in effect at the reference date time
    final boolean shouldUseDST = !referenceDateTimeZone.isStandardOffset(referenceDateTime.getMillis());
    if (shouldUseDST) {
        return DateTimeZone.forOffsetMillis(referenceDateTimeZone.getOffset(referenceDateTime.getMillis()));
    } else {
        return DateTimeZone.forOffsetMillis(referenceDateTimeZone.getStandardOffset(referenceDateTime.getMillis()));
    }
}
Also used : DateTimeZone(org.joda.time.DateTimeZone) DateTime(org.joda.time.DateTime)

Example 35 with DateTime

use of org.joda.time.DateTime in project openhab1-addons by openhab.

the class SonosZonePlayer method setAlarm.

public boolean setAlarm(boolean alarmSwitch) {
    List<SonosAlarm> sonosAlarms = getCurrentAlarmList();
    if (isConfigured()) {
        // find the nearest alarm - take the current time from the Sonos System, not the system where openhab is
        // running
        String currentLocalTime = getTime();
        DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
        DateTime currentDateTime = fmt.parseDateTime(currentLocalTime);
        Duration shortestDuration = Period.days(10).toStandardDuration();
        SonosAlarm firstAlarm = null;
        for (SonosAlarm anAlarm : sonosAlarms) {
            Duration duration = new Duration(currentDateTime, anAlarm.getStartTime());
            if (anAlarm.getStartTime().isBefore(currentDateTime.plus(shortestDuration)) && anAlarm.getRoomUUID().equals(udn.getIdentifierString())) {
                shortestDuration = duration;
                firstAlarm = anAlarm;
            }
        }
        // Set the Alarm
        if (firstAlarm != null) {
            if (alarmSwitch) {
                firstAlarm.setEnabled(true);
            } else {
                firstAlarm.setEnabled(false);
            }
            return updateAlarm(firstAlarm);
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Also used : Duration(org.joda.time.Duration) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTime(org.joda.time.DateTime)

Aggregations

DateTime (org.joda.time.DateTime)3596 Test (org.junit.Test)1091 Test (org.testng.annotations.Test)499 DateTimeRfc1123 (com.microsoft.rest.DateTimeRfc1123)349 ResponseBody (okhttp3.ResponseBody)332 ArrayList (java.util.ArrayList)322 LocalDate (org.joda.time.LocalDate)257 Date (java.util.Date)246 Interval (org.joda.time.Interval)204 Result (io.druid.query.Result)153 HashMap (java.util.HashMap)149 ServiceCall (com.microsoft.rest.ServiceCall)148 List (java.util.List)137 BigDecimal (java.math.BigDecimal)132 DateTimeZone (org.joda.time.DateTimeZone)129 UUID (java.util.UUID)104 LocalDateTime (org.joda.time.LocalDateTime)103 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)95 IOException (java.io.IOException)94 Map (java.util.Map)90