Example usage for org.joda.time LocalDate LocalDate

List of usage examples for org.joda.time LocalDate LocalDate

Introduction

In this page you can find the example usage for org.joda.time LocalDate LocalDate.

Prototype

public LocalDate(int year, int monthOfYear, int dayOfMonth) 

Source Link

Document

Constructs an instance set to the specified date and time using ISOChronology.

Usage

From source file:com.metinkale.prayerapp.vakit.times.IGMGTimes.java

License:Apache License

protected boolean parseResult(String result) {
    result = result.substring(result.indexOf("<div class='zeiten'>") + 20);
    String[] zeiten = result.split("</div><div class='zeiten'>");
    int i = 0;//  w  w w.j  ava2  s . co m
    for (String zeit : zeiten) {
        if (zeit.contains("turkish")) {
            continue;
        }
        String tarih = extractLine(zeit.substring(zeit.indexOf("tarih")));
        String imsak = extractLine(zeit.substring(zeit.indexOf("imsak")));
        String gunes = extractLine(zeit.substring(zeit.indexOf("gunes")));
        String ogle = extractLine(zeit.substring(zeit.indexOf("ogle")));
        String ikindi = extractLine(zeit.substring(zeit.indexOf("ikindi")));
        String aksam = extractLine(zeit.substring(zeit.indexOf("aksam")));
        String yatsi = extractLine(zeit.substring(zeit.indexOf("yatsi")));

        int _d = Integer.parseInt(tarih.substring(0, 2));
        int _m = Integer.parseInt(tarih.substring(3, 5));
        int _y = Integer.parseInt(tarih.substring(6, 10));
        try {
            setTimes(new LocalDate(_y, _m, _d), new String[] { imsak, gunes, ogle, ikindi, aksam, yatsi });
        } catch (IllegalFieldValueException ignore) {
            i++;
        }
    }

    return i > 25;
}

From source file:com.metinkale.prayerapp.vakit.times.MalaysiaTimes.java

License:Apache License

protected boolean parseResult(@NonNull String result) {
    String date = result.substring(result.indexOf("muatturun"));
    date = date.substring(date.indexOf("year=") + 5);
    int year = Integer.parseInt(date.substring(0, 4));
    date = date.substring(date.indexOf("bulan") + 6);
    int month = Integer.parseInt(date.substring(0, date.indexOf("\"")));

    result = result.substring(result.indexOf("#7C7C7C"));
    result = result.substring(0, result.indexOf("<table"));
    int x = 0;//w w  w .  j av  a2 s  . c o  m
    FOR1: for (result = result.substring(result.indexOf("<tr", 1)); result
            .contains("tr "); result = result.substring(result.indexOf("<tr", 1))) {
        try {
            result = result.substring(result.indexOf("<font") + 1);
            String d = extract(result);
            if (d.startsWith("Tarikh"))
                continue;
            int day = Integer.parseInt(d.substring(0, 2));
            result = result.substring(result.indexOf("<font") + 1);
            result = result.substring(result.indexOf("<font") + 1);
            String imsak = extract(result);
            result = result.substring(result.indexOf("<font") + 1);
            result = result.substring(result.indexOf("<font") + 1);
            String sun = extract(result);
            result = result.substring(result.indexOf("<font") + 1);
            String ogle = extract(result);
            result = result.substring(result.indexOf("<font") + 1);
            String ikindi = extract(result);
            result = result.substring(result.indexOf("<font") + 1);
            String aksam = extract(result);
            result = result.substring(result.indexOf("<font") + 1);
            String yatsi = extract(result);

            String[] array = new String[] { imsak, sun, ogle, ikindi, aksam, yatsi };
            for (int i = 0; i < array.length; i++) {
                array[i] = array[i].replace(".", ":");
                if (array[i].length() == 4)
                    array[i] = "0" + array[i];
                if (array[i].length() != 5)
                    continue FOR1;
            }
            setTimes(new LocalDate(year, month, day), array);
            x++;
        } catch (Exception ignore) {
            ignore.printStackTrace();
        }
    }

    return x > 25;
}

From source file:com.metinkale.prayerapp.vakit.times.MoroccoTimes.java

License:Apache License

protected boolean parseResult(@NonNull String result) {
    String temp = result.substring(result.indexOf("colspan=\"4\" class=\"cournt\""));
    temp = temp.substring(temp.indexOf(">") + 1);
    temp = temp.substring(0, temp.indexOf("<")).replace(" ", "");
    int month = Integer.parseInt(temp.substring(0, temp.indexOf("/")));
    int year = Integer.parseInt(temp.substring(temp.indexOf("/") + 1));
    result = result.substring(result.indexOf("<td>") + 4);
    result = result.replace(" ", "").replace("\t", "").replace("\n", "").replace("\r", "");
    String[] zeiten = result.split("<td>");
    int x = 0;/*from w w w  . java 2 s  . co m*/
    for (int i = 0; i < zeiten.length; i++) {
        int day = Integer.parseInt(extract(zeiten[i]));
        String imsak = extract(zeiten[++i]);
        String gunes = extract(zeiten[++i]);
        String ogle = extract(zeiten[++i]);
        String ikindi = extract(zeiten[++i]);
        String aksam = extract(zeiten[++i]);
        String yatsi = extract(zeiten[++i]);

        setTimes(new LocalDate(year, month, day), new String[] { imsak, gunes, ogle, ikindi, aksam, yatsi });
        x++;
    }

    return x > 25;
}

From source file:com.metinkale.prayerapp.vakit.times.NVCTimes.java

License:Apache License

protected boolean parseResult(@NonNull String result) {
    int i = 0;//from   ww w  .  j av  a 2  s.  co  m
    String[] lines = result.split("\n");

    int y = LocalDate.now().getYear();
    for (String line : lines) {
        if (line.contains("<prayertimes")) {
            String day = line.substring(line.indexOf("day=") + 5);
            String month = line.substring(line.indexOf("month=") + 7);
            day = day.substring(0, day.indexOf("\""));
            month = month.substring(0, month.indexOf("\""));
            if (day.length() == 1) {
                day = "0" + day;
            }
            if (month.length() == 1) {
                month = "0" + month;
            }
            String data = line.substring(line.indexOf(">") + 1, line.lastIndexOf("<"));
            data = data.replace("*", "").replace("\t", " ");
            List<String> d = new ArrayList<>(Arrays.asList(data.split(" ")));
            d.remove(15);
            d.remove(14);
            d.remove(13);
            d.remove(12);
            d.remove(10);
            d.remove(8);
            d.remove(7);
            d.remove(4);
            d.remove(3);
            d.remove(1);

            data = "";
            for (String s : d) {
                if (s.length() == 4) {
                    data += " 0" + s;
                } else {
                    data += " " + s;
                }
            }
            setTimes(new LocalDate(y, Integer.parseInt(month), Integer.parseInt(day)),
                    data.substring(1).split(" "));
            i++;
        }

    }
    return i > 25;
}

From source file:com.mycollab.module.user.accountsettings.team.view.UserCustomizeReportOutputWindow.java

License:Open Source License

@Override
protected Object[] buildSampleData() {
    return new Object[] { "John Adams", "Administrator", "john.adam@mycollab.com",
            UserUIContext.formatDate(new LocalDate(1979, 3, 13).toDate()), "11111111", "11111111", "MyCollab" };
}

From source file:com.ning.billing.invoice.generator.InvoiceDateUtils.java

License:Apache License

public static LocalDate calculateLastBillingCycleDateBefore(final LocalDate date,
        final LocalDate previousBillCycleDate, final int billingCycleDay, final BillingPeriod billingPeriod) {
    LocalDate proposedDate = previousBillCycleDate;

    int numberOfPeriods = 0;
    while (!proposedDate.isAfter(date)) {
        proposedDate = previousBillCycleDate.plusMonths(numberOfPeriods * billingPeriod.getNumberOfMonths());
        numberOfPeriods += 1;//w  w  w. j  a  va  2s.  c  o  m
    }

    proposedDate = proposedDate.plusMonths(-billingPeriod.getNumberOfMonths());

    if (proposedDate.dayOfMonth().get() < billingCycleDay) {
        final int lastDayOfTheMonth = proposedDate.dayOfMonth().getMaximumValue();
        if (lastDayOfTheMonth < billingCycleDay) {
            proposedDate = new LocalDate(proposedDate.getYear(), proposedDate.getMonthOfYear(),
                    lastDayOfTheMonth);
        } else {
            proposedDate = new LocalDate(proposedDate.getYear(), proposedDate.getMonthOfYear(),
                    billingCycleDay);
        }
    }

    if (proposedDate.isBefore(previousBillCycleDate)) {
        // Make sure not to go too far in the past
        return previousBillCycleDate;
    } else {
        return proposedDate;
    }
}

From source file:com.ning.billing.osgi.bundles.analytics.AnalyticsTestSuiteNoDB.java

License:Apache License

protected InvoiceItem createInvoiceItem(final UUID invoiceId, final InvoiceItemType type,
        final BigDecimal amount) {
    return createInvoiceItem(invoiceId, type, UUID.randomUUID(), new LocalDate(2013, 1, 2),
            new LocalDate(2013, 2, 5), amount, null);
}

From source file:com.ning.billing.osgi.bundles.analytics.AnalyticsTestSuiteNoDB.java

License:Apache License

@BeforeMethod(groups = "fast")
public void setUp() throws Exception {
    account = Mockito.mock(Account.class);
    Mockito.when(account.getId()).thenReturn(UUID.randomUUID());
    Mockito.when(account.getExternalKey()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(account.getName()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(account.getFirstNameLength()).thenReturn(4);
    Mockito.when(account.getEmail()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(account.getBillCycleDayLocal()).thenReturn(2);
    Mockito.when(account.getCurrency()).thenReturn(Currency.BRL);
    Mockito.when(account.getPaymentMethodId()).thenReturn(UUID.randomUUID());
    Mockito.when(account.getTimeZone()).thenReturn(DateTimeZone.forID("Europe/London"));
    Mockito.when(account.getLocale()).thenReturn(UUID.randomUUID().toString().substring(0, 5));
    Mockito.when(account.getAddress1()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(account.getAddress2()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(account.getCompanyName()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(account.getCity()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(account.getStateOrProvince()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(account.getPostalCode()).thenReturn(UUID.randomUUID().toString().substring(0, 16));
    Mockito.when(account.getCountry()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(account.getPhone()).thenReturn(UUID.randomUUID().toString().substring(0, 25));
    Mockito.when(account.isMigrated()).thenReturn(true);
    Mockito.when(account.isNotifiedForInvoices()).thenReturn(true);
    Mockito.when(account.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 47, DateTimeZone.UTC));
    Mockito.when(account.getUpdatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 48, DateTimeZone.UTC));
    final UUID accountId = account.getId();

    bundle = Mockito.mock(SubscriptionBundle.class);
    Mockito.when(bundle.getId()).thenReturn(UUID.randomUUID());
    Mockito.when(bundle.getAccountId()).thenReturn(accountId);
    Mockito.when(bundle.getExternalKey()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(bundle.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 48, DateTimeZone.UTC));
    final UUID bundleId = bundle.getId();

    final Product product = Mockito.mock(Product.class);
    Mockito.when(product.getName()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(product.isRetired()).thenReturn(true);
    Mockito.when(product.getCategory()).thenReturn(ProductCategory.STANDALONE);
    Mockito.when(product.getCatalogName()).thenReturn(UUID.randomUUID().toString());

    plan = Mockito.mock(Plan.class);
    Mockito.when(plan.getProduct()).thenReturn(product);
    Mockito.when(plan.getName()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(plan.isRetired()).thenReturn(true);
    Mockito.when(plan.getBillingPeriod()).thenReturn(BillingPeriod.QUARTERLY);
    Mockito.when(plan.getEffectiveDateForExistingSubscriptons())
            .thenReturn(new DateTime(2016, 1, 22, 10, 56, 59, DateTimeZone.UTC).toDate());
    final String planName = plan.getName();

    phase = Mockito.mock(PlanPhase.class);
    Mockito.when(phase.getBillingPeriod()).thenReturn(BillingPeriod.QUARTERLY);
    Mockito.when(phase.getName()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(phase.getPlan()).thenReturn(plan);
    Mockito.when(phase.getPhaseType()).thenReturn(PhaseType.DISCOUNT);
    final String phaseName = phase.getName();

    priceList = Mockito.mock(PriceList.class);
    Mockito.when(priceList.getName()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(priceList.isRetired()).thenReturn(false);

    subscriptionTransition = Mockito.mock(SubscriptionTransition.class);
    Mockito.when(subscriptionTransition.getSubscriptionId()).thenReturn(UUID.randomUUID());
    Mockito.when(subscriptionTransition.getBundleId()).thenReturn(bundleId);
    Mockito.when(subscriptionTransition.getNextState()).thenReturn(SubscriptionState.ACTIVE);
    Mockito.when(subscriptionTransition.getNextPlan()).thenReturn(plan);
    Mockito.when(subscriptionTransition.getNextPhase()).thenReturn(phase);
    Mockito.when(subscriptionTransition.getNextPriceList()).thenReturn(priceList);
    Mockito.when(subscriptionTransition.getRequestedTransitionTime())
            .thenReturn(new DateTime(2010, 1, 2, 3, 4, 5, DateTimeZone.UTC));
    Mockito.when(subscriptionTransition.getEffectiveTransitionTime())
            .thenReturn(new DateTime(2011, 2, 3, 4, 5, 6, DateTimeZone.UTC));
    Mockito.when(subscriptionTransition.getTransitionType()).thenReturn(SubscriptionTransitionType.CREATE);
    Mockito.when(subscriptionTransition.getNextEventCreatedDate())
            .thenReturn(new DateTime(2016, 1, 22, 10, 56, 49, DateTimeZone.UTC));
    Mockito.when(subscriptionTransition.getNextEventId()).thenReturn(UUID.randomUUID());
    final UUID subscriptionId = subscriptionTransition.getSubscriptionId();
    final UUID nextEventId = subscriptionTransition.getNextEventId();

    blockingState = Mockito.mock(BlockingState.class);
    Mockito.when(blockingState.getId()).thenReturn(UUID.randomUUID());
    Mockito.when(blockingState.getBlockedId()).thenReturn(bundleId);
    Mockito.when(blockingState.getStateName()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(blockingState.getType()).thenReturn(Type.SUBSCRIPTION_BUNDLE);
    Mockito.when(blockingState.getTimestamp())
            .thenReturn(new DateTime(2010, 2, 2, 4, 22, 22, DateTimeZone.UTC));
    Mockito.when(blockingState.isBlockBilling()).thenReturn(true);
    Mockito.when(blockingState.isBlockChange()).thenReturn(false);
    Mockito.when(blockingState.isBlockEntitlement()).thenReturn(true);
    Mockito.when(blockingState.getDescription()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(blockingState.getService()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(blockingState.getCreatedDate())
            .thenReturn(new DateTime(2016, 1, 22, 10, 56, 0, DateTimeZone.UTC));
    final UUID blockingStateId = blockingState.getId();

    invoiceItem = Mockito.mock(InvoiceItem.class);
    Mockito.when(invoiceItem.getId()).thenReturn(UUID.randomUUID());
    Mockito.when(invoiceItem.getInvoiceItemType()).thenReturn(InvoiceItemType.EXTERNAL_CHARGE);
    Mockito.when(invoiceItem.getInvoiceId()).thenReturn(UUID.randomUUID());
    Mockito.when(invoiceItem.getAccountId()).thenReturn(UUID.randomUUID());
    Mockito.when(invoiceItem.getStartDate()).thenReturn(new LocalDate(1999, 9, 9));
    Mockito.when(invoiceItem.getEndDate()).thenReturn(new LocalDate(2048, 1, 1));
    Mockito.when(invoiceItem.getAmount()).thenReturn(new BigDecimal("12000"));
    Mockito.when(invoiceItem.getCurrency()).thenReturn(Currency.EUR);
    Mockito.when(invoiceItem.getDescription()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(invoiceItem.getBundleId()).thenReturn(bundleId);
    Mockito.when(invoiceItem.getSubscriptionId()).thenReturn(subscriptionId);
    Mockito.when(invoiceItem.getPlanName()).thenReturn(planName);
    Mockito.when(invoiceItem.getPhaseName()).thenReturn(phaseName);
    Mockito.when(invoiceItem.getRate()).thenReturn(new BigDecimal("1203"));
    Mockito.when(invoiceItem.getLinkedItemId()).thenReturn(UUID.randomUUID());
    Mockito.when(invoiceItem.getCreatedDate())
            .thenReturn(new DateTime(2016, 1, 22, 10, 56, 51, DateTimeZone.UTC));
    final UUID invoiceItemId = invoiceItem.getId();

    final UUID invoiceId = UUID.randomUUID();

    invoicePayment = Mockito.mock(InvoicePayment.class);
    Mockito.when(invoicePayment.getId()).thenReturn(UUID.randomUUID());
    Mockito.when(invoicePayment.getPaymentId()).thenReturn(UUID.randomUUID());
    Mockito.when(invoicePayment.getType()).thenReturn(InvoicePaymentType.ATTEMPT);
    Mockito.when(invoicePayment.getInvoiceId()).thenReturn(invoiceId);
    Mockito.when(invoicePayment.getPaymentDate())
            .thenReturn(new DateTime(2003, 4, 12, 3, 34, 52, DateTimeZone.UTC));
    Mockito.when(invoicePayment.getAmount()).thenReturn(BigDecimal.ONE);
    Mockito.when(invoicePayment.getCurrency()).thenReturn(Currency.MXN);
    Mockito.when(invoicePayment.getLinkedInvoicePaymentId()).thenReturn(UUID.randomUUID());
    Mockito.when(invoicePayment.getPaymentCookieId()).thenReturn(UUID.randomUUID());
    Mockito.when(invoicePayment.getCreatedDate()).thenReturn(INVOICE_CREATED_DATE);
    final UUID invoicePaymentId = invoicePayment.getId();

    invoice = Mockito.mock(Invoice.class);
    Mockito.when(invoice.getId()).thenReturn(invoiceId);
    Mockito.when(invoice.getInvoiceItems()).thenReturn(ImmutableList.<InvoiceItem>of(invoiceItem));
    Mockito.when(invoice.getNumberOfItems()).thenReturn(1);
    Mockito.when(invoice.getPayments()).thenReturn(ImmutableList.<InvoicePayment>of(invoicePayment));
    Mockito.when(invoice.getNumberOfPayments()).thenReturn(1);
    Mockito.when(invoice.getAccountId()).thenReturn(accountId);
    Mockito.when(invoice.getInvoiceNumber()).thenReturn(42);
    Mockito.when(invoice.getInvoiceDate()).thenReturn(new LocalDate(1954, 12, 1));
    Mockito.when(invoice.getTargetDate()).thenReturn(new LocalDate(2017, 3, 4));
    Mockito.when(invoice.getCurrency()).thenReturn(Currency.AUD);
    Mockito.when(invoice.getPaidAmount()).thenReturn(BigDecimal.ZERO);
    Mockito.when(invoice.getOriginalChargedAmount()).thenReturn(new BigDecimal("1922"));
    Mockito.when(invoice.getChargedAmount()).thenReturn(new BigDecimal("100293"));
    Mockito.when(invoice.getCreditedAmount()).thenReturn(new BigDecimal("283"));
    Mockito.when(invoice.getRefundedAmount()).thenReturn(new BigDecimal("384"));
    Mockito.when(invoice.getBalance()).thenReturn(new BigDecimal("18376"));
    Mockito.when(invoice.isMigrationInvoice()).thenReturn(false);
    Mockito.when(invoice.getCreatedDate()).thenReturn(INVOICE_CREATED_DATE);

    paymentAttempt = Mockito.mock(PaymentAttempt.class);
    Mockito.when(paymentAttempt.getId()).thenReturn(UUID.randomUUID());
    Mockito.when(paymentAttempt.getEffectiveDate())
            .thenReturn(new DateTime(2019, 12, 30, 10, 10, 10, DateTimeZone.UTC));
    Mockito.when(paymentAttempt.getGatewayErrorCode()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(paymentAttempt.getGatewayErrorMsg()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(paymentAttempt.getPaymentStatus()).thenReturn(PaymentStatus.SUCCESS);
    Mockito.when(paymentAttempt.getCreatedDate())
            .thenReturn(new DateTime(2016, 1, 22, 10, 56, 54, DateTimeZone.UTC));

    final PaymentMethodPlugin paymentMethodPlugin = Mockito.mock(PaymentMethodPlugin.class);
    Mockito.when(paymentMethodPlugin.getExternalPaymentMethodId()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(paymentMethodPlugin.isDefaultPaymentMethod()).thenReturn(true);

    paymentMethod = Mockito.mock(PaymentMethod.class);
    Mockito.when(paymentMethod.getId()).thenReturn(UUID.randomUUID());
    Mockito.when(paymentMethod.getAccountId()).thenReturn(accountId);
    Mockito.when(paymentMethod.isActive()).thenReturn(true);
    Mockito.when(paymentMethod.getPluginName()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(paymentMethod.getPluginDetail()).thenReturn(paymentMethodPlugin);
    Mockito.when(paymentMethod.getCreatedDate())
            .thenReturn(new DateTime(2016, 1, 22, 10, 56, 55, DateTimeZone.UTC));
    final UUID paymentMethodId = paymentMethod.getId();

    payment = Mockito.mock(Payment.class);
    Mockito.when(payment.getId()).thenReturn(UUID.randomUUID());
    Mockito.when(payment.getAccountId()).thenReturn(accountId);
    Mockito.when(payment.getInvoiceId()).thenReturn(invoiceId);
    Mockito.when(payment.getPaymentMethodId()).thenReturn(paymentMethodId);
    Mockito.when(payment.getPaymentNumber()).thenReturn(1);
    Mockito.when(payment.getAmount()).thenReturn(new BigDecimal("199999"));
    Mockito.when(payment.getPaidAmount()).thenReturn(new BigDecimal("199998"));
    Mockito.when(payment.getEffectiveDate()).thenReturn(new DateTime(2019, 2, 3, 12, 12, 12, DateTimeZone.UTC));
    Mockito.when(payment.getCurrency()).thenReturn(Currency.USD);
    Mockito.when(payment.getPaymentStatus()).thenReturn(PaymentStatus.AUTO_PAY_OFF);
    Mockito.when(payment.getAttempts()).thenReturn(ImmutableList.<PaymentAttempt>of(paymentAttempt));
    Mockito.when(payment.getExtFirstPaymentIdRef()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(payment.getExtSecondPaymentIdRef()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(payment.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 56, DateTimeZone.UTC));

    refund = Mockito.mock(Refund.class);
    Mockito.when(refund.getId()).thenReturn(UUID.randomUUID());
    Mockito.when(refund.getPaymentId()).thenReturn(UUID.randomUUID());
    Mockito.when(refund.isAdjusted()).thenReturn(true);
    Mockito.when(refund.getRefundAmount()).thenReturn(BigDecimal.TEN);
    Mockito.when(refund.getCurrency()).thenReturn(Currency.BRL);
    Mockito.when(refund.getEffectiveDate()).thenReturn(new DateTime(2015, 2, 2, 10, 56, 5, DateTimeZone.UTC));

    customField = Mockito.mock(CustomField.class);
    Mockito.when(customField.getId()).thenReturn(UUID.randomUUID());
    Mockito.when(customField.getObjectId()).thenReturn(UUID.randomUUID());
    Mockito.when(customField.getObjectType()).thenReturn(ObjectType.TENANT);
    Mockito.when(customField.getFieldName()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(customField.getFieldValue()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(customField.getCreatedDate())
            .thenReturn(new DateTime(2016, 1, 22, 10, 56, 57, DateTimeZone.UTC));
    final UUID fieldId = customField.getId();

    tag = Mockito.mock(Tag.class);
    Mockito.when(tag.getObjectId()).thenReturn(UUID.randomUUID());
    Mockito.when(tag.getObjectType()).thenReturn(ObjectType.ACCOUNT);
    Mockito.when(tag.getTagDefinitionId()).thenReturn(UUID.randomUUID());
    Mockito.when(tag.getCreatedDate()).thenReturn(new DateTime(2016, 1, 22, 10, 56, 58, DateTimeZone.UTC));
    final UUID tagId = tag.getId();

    tagDefinition = Mockito.mock(TagDefinition.class);
    Mockito.when(tagDefinition.getId()).thenReturn(UUID.randomUUID());
    Mockito.when(tagDefinition.getName()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(tagDefinition.getDescription()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(tagDefinition.isControlTag()).thenReturn(false);
    Mockito.when(tagDefinition.getApplicableObjectTypes())
            .thenReturn(ImmutableList.<ObjectType>of(ObjectType.INVOICE));
    Mockito.when(tagDefinition.getCreatedDate())
            .thenReturn(new DateTime(2016, 1, 22, 10, 56, 59, DateTimeZone.UTC));

    auditLog = Mockito.mock(AuditLog.class);
    Mockito.when(auditLog.getId()).thenReturn(UUID.randomUUID());
    Mockito.when(auditLog.getChangeType()).thenReturn(ChangeType.INSERT);
    Mockito.when(auditLog.getUserName()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(auditLog.getCreatedDate())
            .thenReturn(new DateTime(2012, 12, 31, 23, 59, 59, DateTimeZone.UTC));
    Mockito.when(auditLog.getReasonCode()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(auditLog.getUserToken()).thenReturn(UUID.randomUUID().toString());
    Mockito.when(auditLog.getComment()).thenReturn(UUID.randomUUID().toString());

    // Real class for the binding to work with JDBI
    callContext = new TestCallContext();
    final UUID tenantId = callContext.getTenantId();

    final RecordIdApi recordIdApi = Mockito.mock(RecordIdApi.class);
    Mockito.when(recordIdApi.getRecordId(accountId, ObjectType.ACCOUNT, callContext))
            .thenReturn(accountRecordId);
    Mockito.when(recordIdApi.getRecordId(nextEventId, ObjectType.SUBSCRIPTION_EVENT, callContext))
            .thenReturn(subscriptionEventRecordId);
    Mockito.when(recordIdApi.getRecordId(invoiceId, ObjectType.INVOICE, callContext))
            .thenReturn(invoiceRecordId);
    Mockito.when(recordIdApi.getRecordId(invoiceItemId, ObjectType.INVOICE_ITEM, callContext))
            .thenReturn(invoiceItemRecordId);
    Mockito.when(recordIdApi.getRecordId(invoicePaymentId, ObjectType.INVOICE_PAYMENT, callContext))
            .thenReturn(invoicePaymentRecordId);
    Mockito.when(recordIdApi.getRecordId(blockingStateId, ObjectType.BLOCKING_STATES, callContext))
            .thenReturn(blockingStateRecordId);
    Mockito.when(recordIdApi.getRecordId(fieldId, ObjectType.CUSTOM_FIELD, callContext))
            .thenReturn(fieldRecordId);// w w w.j a  v a  2  s . c  o  m
    Mockito.when(recordIdApi.getRecordId(tagId, ObjectType.TAG, callContext)).thenReturn(tagRecordId);
    Mockito.when(recordIdApi.getRecordId(tenantId, ObjectType.TENANT, callContext)).thenReturn(tenantRecordId);

    killbillAPI = Mockito.mock(OSGIKillbillAPI.class);
    Mockito.when(killbillAPI.getRecordIdApi()).thenReturn(recordIdApi);

    killbillDataSource = Mockito.mock(OSGIKillbillDataSource.class);
}

From source file:com.rappsantiago.weighttracker.goal.EditGoalsFragment.java

License:Apache License

@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    LocalDate date = new LocalDate(year, monthOfYear + 1, dayOfMonth);
    mDueDateInMillis = date.toDate().getTime();
    mLblDueDate.setText(DisplayUtil.getReadableDate(mDueDateInMillis));
}

From source file:com.rappsantiago.weighttracker.profile.setup.NameBirthdayGenderFragment.java

License:Apache License

@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    LocalDate date = new LocalDate(year, monthOfYear + 1, dayOfMonth);
    mBirthdayInMillis = date.toDate().getTime();
    mLblBirthday.setText(DisplayUtil.getReadableDate(mBirthdayInMillis));
}