Example usage for org.joda.time DateTime toString

List of usage examples for org.joda.time DateTime toString

Introduction

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

Prototype

public String toString(String pattern) 

Source Link

Document

Output the instant using the specified format pattern.

Usage

From source file:com.money.manager.ex.datalayer.StockHistoryRepository.java

License:Open Source License

public ContentValues getContentValues(String symbol, Money price, DateTime date) {
    String isoDate = date.toString(Constants.ISO_DATE_FORMAT);

    ContentValues values = new ContentValues();
    values.put(StockHistory.SYMBOL, symbol);
    values.put(StockHistory.DATE, isoDate);
    values.put(StockHistory.VALUE, price.toString());
    values.put(StockHistory.UPDTYPE, UpdateType.Online.type);

    return values;
}

From source file:com.money.manager.ex.datalayer.StockHistoryRepositorySql.java

License:Open Source License

public ContentValues getContentValues(String symbol, Money price, DateTime date) {
    String isoDate = date.toString(Constants.ISO_DATE_FORMAT);

    ContentValues values = new ContentValues();
    values.put(StockHistory.SYMBOL, symbol);
    values.put(StockHistory.DATE, isoDate);
    values.put(StockHistory.VALUE, price.toString());
    values.put(StockHistory.UPDTYPE, StockHistoryRepository.UpdateType.Online.type);

    return values;
}

From source file:com.money.manager.ex.domainmodel.AccountTransaction.java

License:Open Source License

public void setDate(DateTime value) {
    String dateString = value.toString(Constants.ISO_DATE_FORMAT);
    setString(ITransactionEntity.TRANSDATE, dateString);
}

From source file:com.money.manager.ex.home.DashboardFragment.java

License:Open Source License

private void showChartIncomeVsExpensesCurrentMonth(Cursor cursor) {
    // move to first
    if (!cursor.moveToFirst())
        return;/*from w  w  w  .ja  v  a  2 s  .  co m*/
    // arrays
    double[] incomes = new double[3];
    double[] expenses = new double[3];
    String[] titles = new String[3];

    // incomes and expenses
    incomes[1] = cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Income));
    expenses[1] = Math.abs(cursor.getDouble(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Expenses)));
    // titles
    int year = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.YEAR));
    int month = cursor.getInt(cursor.getColumnIndex(IncomeVsExpenseReportEntity.Month));

    // format month
    //        Calendar calendar = Calendar.getInstance();
    //        calendar.set(year, month - 1, 1);
    DateTime dateTime = MmxDateTimeUtils.from(year, month - 1, 1);
    // titles
    //        titles[1] = Integer.toString(year) + "-" + new SimpleDateFormat("MMM").format(calendar.getTime());
    titles[1] = Integer.toString(year) + "-" + dateTime.toString("MMM");

    // compose bundle for arguments
    Bundle args = new Bundle();
    args.putDoubleArray(IncomeVsExpensesChartFragment.KEY_EXPENSES_VALUES, expenses);
    args.putDoubleArray(IncomeVsExpensesChartFragment.KEY_INCOME_VALUES, incomes);
    args.putStringArray(IncomeVsExpensesChartFragment.KEY_XTITLES, titles);
    args.putString(IncomeVsExpensesChartFragment.KEY_TITLE,
            getString(R.string.income_vs_expenses_current_month));
    args.putBoolean(IncomeVsExpensesChartFragment.KEY_DISPLAY_AS_UP_ENABLED, false);

    // get fragment manager
    FragmentManager fragmentManager = getChildFragmentManager();
    if (fragmentManager != null) {
        IncomeVsExpensesChartFragment fragment;

        fragment = new IncomeVsExpensesChartFragment();
        fragment.setChartArguments(args);

        if (fragment.isVisible())
            fragment.onResume();

        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.linearLayoutScreen1, fragment,
                IncomeVsExpensesChartFragment.class.getSimpleName());

        fragmentTransaction.commit();
    }
}

From source file:com.money.manager.ex.investment.InvestmentTransactionEditActivity.java

License:Open Source License

private void initDateControl(final InvestmentTransactionViewHolder viewHolder) {
    // Purchase Date

    viewHolder.dateView.setOnClickListener(new View.OnClickListener() {
        CalendarDatePickerDialogFragment.OnDateSetListener listener = new CalendarDatePickerDialogFragment.OnDateSetListener() {
            @Override/* w  w w  . j ava 2s.  c om*/
            public void onDateSet(CalendarDatePickerDialogFragment dialog, int year, int monthOfYear,
                    int dayOfMonth) {
                setDirty(true);

                DateTime dateTime = MmxDateTimeUtils.from(year, monthOfYear + 1, dayOfMonth);
                viewHolder.dateView.setText(dateTime.toString(Constants.LONG_DATE_PATTERN));
            }
        };

        @Override
        public void onClick(View v) {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(mStock.getPurchaseDate().toDate());

            CalendarDatePickerDialogFragment datePicker = new CalendarDatePickerDialogFragment()
                    .setFirstDayOfWeek(MmxDateTimeUtils.getFirstDayOfWeek()).setOnDateSetListener(listener)
                    .setPreselectedDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                            calendar.get(Calendar.DAY_OF_MONTH));
            if (new UIHelper(InvestmentTransactionEditActivity.this).isDarkTheme()) {
                datePicker.setThemeDark();
            }
            datePicker.show(getSupportFragmentManager(), DATEPICKER_TAG);
        }
    });
    // prev/next day
    viewHolder.previousDayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DateTime dateTime = mStock.getPurchaseDate().minusDays(1);
            setDate(dateTime);
        }
    });
    viewHolder.nextDayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DateTime dateTime = mStock.getPurchaseDate().plusDays(1);
            setDate(dateTime);
        }
    });
}

From source file:com.money.manager.ex.investment.InvestmentTransactionEditActivity.java

License:Open Source License

private void showDate(DateTime date) {
    mViewHolder.dateView.setText(date.toString(Constants.LONG_DATE_PATTERN));
}

From source file:com.money.manager.ex.recurring.transactions.RecurringTransactionEditActivity.java

License:Open Source License

private void initializePaymentDateSelector() {
    if (mViewHolder.paymentDateTextView == null)
        return;/*from   ww w  . j av a 2s. c  o  m*/

    DateTime paymentDate = getRecurringTransaction().getPaymentDate();
    mViewHolder.paymentDateTextView.setText(paymentDate.toString(Constants.LONG_DATE_PATTERN));
    //        mViewHolder.paymentDateTextView.setTag(paymentDate.toString(Constants.ISO_DATE_FORMAT));

    mViewHolder.paymentDateTextView.setOnClickListener(new View.OnClickListener() {
        CalendarDatePickerDialogFragment.OnDateSetListener listener = new CalendarDatePickerDialogFragment.OnDateSetListener() {
            @Override
            public void onDateSet(CalendarDatePickerDialogFragment dialog, int year, int monthOfYear,
                    int dayOfMonth) {
                DateTime dateTime = MmxDateTimeUtils.from(year, monthOfYear + 1, dayOfMonth);

                setPaymentDate(dateTime);
            }
        };

        @Override
        public void onClick(View v) {
            // Show calendar with the current date selected.

            DateTime dateTime = getPaymentDate();

            CalendarDatePickerDialogFragment datePicker = new CalendarDatePickerDialogFragment()
                    .setFirstDayOfWeek(MmxDateTimeUtils.getFirstDayOfWeek()).setOnDateSetListener(listener)
                    .setPreselectedDate(dateTime.getYear(), dateTime.getMonthOfYear() - 1,
                            dateTime.getDayOfMonth());
            if (new UIHelper(RecurringTransactionEditActivity.this).isDarkTheme()) {
                datePicker.setThemeDark();
            }
            datePicker.show(getSupportFragmentManager(), TAG_DATEPICKER);
        }
    });

    mViewHolder.paymentPreviousDayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DateTime dateTime = getPaymentDate().minusDays(1);
            setPaymentDate(dateTime);
        }
    });

    mViewHolder.paymentNextDayButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            DateTime dateTime = getPaymentDate().plusDays(1);
            setPaymentDate(dateTime);
        }
    });
}

From source file:com.money.manager.ex.recurring.transactions.RecurringTransactionEditActivity.java

License:Open Source License

private void setPaymentDate(DateTime dateTime) {
    mCommonFunctions.setDirty(true);/*from w w w.ja va2  s  . c  o  m*/

    getRecurringTransaction().setPaymentDate(dateTime);
    mViewHolder.paymentDateTextView.setText(dateTime.toString(Constants.LONG_DATE_PATTERN));
}

From source file:com.money.manager.ex.transactions.EditTransactionCommonFunctions.java

License:Open Source License

private void showDate(DateTime dateTime) {
    viewHolder.dateTextView.setText(dateTime.toString(Constants.LONG_DATE_PATTERN));
}

From source file:com.money.manager.ex.utils.MmxDateTimeUtils.java

License:Open Source License

public static String getIsoStringFrom(DateTime dateTime) {
    if (dateTime == null)
        return null;

    return dateTime.toString(Constants.ISO_DATE_FORMAT);
}