Search in sources :

Example 11 with LocalDate

use of org.joda.time.LocalDate in project qi4j-sdk by Qi4j.

the class AbstractQueryTest method script41_LocalDate.

@Test
public void script41_LocalDate() {
    QueryBuilder<Person> qb = this.module.newQueryBuilder(Person.class);
    Person person = templateFor(Person.class);
    Query<Person> query = unitOfWork.newQuery(qb.where(ne(person.localDateValue(), new LocalDate("2010-03-04", UTC))));
    System.out.println("*** script41_LocalDate: " + query);
    verifyUnorderedResults(query, "Joe Doe");
}
Also used : Person(org.qi4j.test.indexing.model.Person) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 12 with LocalDate

use of org.joda.time.LocalDate in project qi4j-sdk by Qi4j.

the class AbstractQueryTest method script42_LocalDate.

@Test
public void script42_LocalDate() {
    QueryBuilder<Person> qb = this.module.newQueryBuilder(Person.class);
    Person person = templateFor(Person.class);
    Query<Person> query = unitOfWork.newQuery(qb.where(ne(person.localDateValue(), new LocalDate("2010-03-04", forID("CET")))));
    System.out.println("*** script42_LocalDate: " + query);
    verifyUnorderedResults(query, "Joe Doe");
}
Also used : Person(org.qi4j.test.indexing.model.Person) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 13 with LocalDate

use of org.joda.time.LocalDate in project qi4j-sdk by Qi4j.

the class DateTextFieldWithPicker method earliestDate.

public DateTextFieldWithPicker earliestDate(LocalDate newEarliestDate) {
    if (selectedDate != null && newEarliestDate.isAfter(selectedDate)) {
        throw new IllegalArgumentException("Earliest date can't be before selected day.");
    }
    earliestDate = newEarliestDate;
    // Input field validation - date should be _after_ minimumDate (not the same)
    LocalDate minimumDate = newEarliestDate.minusDays(1);
    Date convertedMinimumDate = new DateTime(minimumDate.toDateTime(new LocalTime())).toDate();
    add(DateValidator.minimum(convertedMinimumDate));
    return this;
}
Also used : LocalTime(org.joda.time.LocalTime) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime)

Example 14 with LocalDate

use of org.joda.time.LocalDate in project SeriesGuide by UweTrottmann.

the class TimeTools method parseEpisodeReleaseDate.

/**
     * Calculates the episode release date time as a millisecond instant. Adjusts for time zone
     * effects on release time, e.g. delays between time zones (e.g. in the United States) and DST.
     *
     * @param showTimeZone See {@link #getDateTimeZone(String)}.
     * @param showReleaseTime See {@link #getShowReleaseTime(int)}.
     * @return -1 if no conversion was possible. Otherwise, any other long value (may be negative!).
     */
public static long parseEpisodeReleaseDate(@Nullable Context context, @NonNull DateTimeZone showTimeZone, @Nullable String releaseDate, @NonNull LocalTime showReleaseTime, @Nullable String showCountry, @Nullable String showNetwork, @NonNull String deviceTimeZone) {
    if (releaseDate == null || releaseDate.length() == 0) {
        return Constants.EPISODE_UNKNOWN_RELEASE;
    }
    // get date
    LocalDate localDate;
    try {
        localDate = TVDB_DATE_FORMATTER.parseLocalDate(releaseDate);
    } catch (IllegalArgumentException e) {
        // date string could not be parsed
        if (context != null) {
            Utils.trackCustomEvent(context, AnalyticsTree.CATEGORY_THETVDB_ERROR, "Date parsing failure", releaseDate);
        }
        Timber.e(e, "TheTVDB date could not be parsed: %s", releaseDate);
        return Constants.EPISODE_UNKNOWN_RELEASE;
    }
    // set time
    LocalDateTime localDateTime = localDate.toLocalDateTime(showReleaseTime);
    localDateTime = handleHourPastMidnight(showCountry, showNetwork, localDateTime);
    localDateTime = handleDstGap(showTimeZone, localDateTime);
    // finally get a valid datetime in the show time zone
    DateTime dateTime = localDateTime.toDateTime(showTimeZone);
    // handle time zone effects on release time for US shows (only if device is set to US zone)
    if (deviceTimeZone.startsWith(TIMEZONE_ID_PREFIX_AMERICA)) {
        dateTime = applyUnitedStatesCorrections(showCountry, deviceTimeZone, dateTime);
    }
    return dateTime.getMillis();
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) LocalDateTime(org.joda.time.LocalDateTime)

Example 15 with LocalDate

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

the class TestJaxrsBase method beforeMethod.

@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
    super.beforeMethod();
    // Because we truncate the tables, the database record_id auto_increment will be reset
    tenantCacheInvalidation.setLatestRecordIdProcessed(0L);
    externalBus.start();
    internalBus.start();
    cacheControllerDispatcher.clearAll();
    busHandler.reset();
    clock.resetDeltaFromReality();
    clock.setDay(new LocalDate(2012, 8, 25));
    // Make sure to re-generate the api key and secret (could be cached by Shiro)
    DEFAULT_API_KEY = UUID.randomUUID().toString();
    DEFAULT_API_SECRET = UUID.randomUUID().toString();
    loginTenant(DEFAULT_API_KEY, DEFAULT_API_SECRET);
    // Recreate the tenant (tables have been cleaned-up)
    final Tenant tenant = new Tenant();
    tenant.setApiKey(DEFAULT_API_KEY);
    tenant.setApiSecret(DEFAULT_API_SECRET);
    killBillClient.createTenant(tenant, createdBy, reason, comment);
}
Also used : Tenant(org.killbill.billing.client.model.Tenant) LocalDate(org.joda.time.LocalDate) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

LocalDate (org.joda.time.LocalDate)1025 Test (org.testng.annotations.Test)553 BigDecimal (java.math.BigDecimal)401 DateTime (org.joda.time.DateTime)230 ArrayList (java.util.ArrayList)211 Invoice (org.killbill.billing.invoice.api.Invoice)165 UUID (java.util.UUID)143 Account (org.killbill.billing.account.api.Account)139 Test (org.junit.Test)137 InvoiceItem (org.killbill.billing.invoice.api.InvoiceItem)118 DefaultEntitlement (org.killbill.billing.entitlement.api.DefaultEntitlement)104 FixedPriceInvoiceItem (org.killbill.billing.invoice.model.FixedPriceInvoiceItem)101 RecurringInvoiceItem (org.killbill.billing.invoice.model.RecurringInvoiceItem)95 ExpectedInvoiceItemCheck (org.killbill.billing.beatrix.util.InvoiceChecker.ExpectedInvoiceItemCheck)85 DefaultInvoice (org.killbill.billing.invoice.model.DefaultInvoice)82 RepairAdjInvoiceItem (org.killbill.billing.invoice.model.RepairAdjInvoiceItem)71 ItemAdjInvoiceItem (org.killbill.billing.invoice.model.ItemAdjInvoiceItem)69 PlanPhaseSpecifier (org.killbill.billing.catalog.api.PlanPhaseSpecifier)63 Date (java.util.Date)57 MockPlan (org.killbill.billing.catalog.MockPlan)52