Example usage for org.joda.time LocalDateTime toString

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

Introduction

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

Prototype

public String toString(String pattern) 

Source Link

Document

Output the date using the specified format pattern.

Usage

From source file:org.apache.gobblin.data.management.copy.TimeAwareRecursiveCopyableDataset.java

License:Apache License

private boolean isDatePatternHourly(String datePattern) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern(datePattern);
    LocalDateTime refDateTime = new LocalDateTime(2017, 01, 01, 10, 0, 0);
    String refDateTimeString = refDateTime.toString(formatter);
    LocalDateTime refDateTimeAtStartOfDay = refDateTime.withHourOfDay(0);
    String refDateTimeStringAtStartOfDay = refDateTimeAtStartOfDay.toString(formatter);
    return !refDateTimeString.equals(refDateTimeStringAtStartOfDay);
}

From source file:org.estatio.dscm.dom.playlist.Playlist.java

License:Apache License

@MultiLine(numberOfLines = 10)
@MemberOrder(sequence = "9")
public String getNextOccurences() {
    StringBuilder builder = new StringBuilder();
    LocalDate fromDate = clockService.now().compareTo(this.getStartDate()) >= 0 ? clockService.now()
            : this.getStartDate();
    for (LocalDateTime occurence : nextOccurences(fromDate.plusDays(7))) {
        builder.append(occurence.toString("yyyy-MM-dd HH:mm"));
        builder.append("\n");
    }//  www  .j  a v  a  2 s  . c  om
    return builder.toString();
}

From source file:org.estatio.dscm.services.SyncService.java

License:Apache License

@Programmatic
public String createPlaylistFilename(Display display, LocalDateTime dateTime) {
    return properties.get("dscm.server.path").concat("/displays").concat("/" + display.getName())
            .concat("/playlists").concat("/" + dateTime.toString("yyyyMMddHHmm"));
}

From source file:org.fixb.impl.NativeFixMessageBuilder.java

License:Apache License

@Override
public FixMessageBuilder<String> setField(int tag, LocalDateTime value, boolean header) {
    final String pattern = (value.getMillisOfSecond() == 0) ? DATE_TIME : DATE_TIME_WITH_MILLIS;
    return setField(tag, value.toString(pattern), header);
}

From source file:org.gdg.frisbee.android.adapter.EventAdapter.java

License:Apache License

@Override
public View getView(int i, View convertView, ViewGroup viewGroup) {

    ViewHolder holder;/*www .ja v  a  2 s  .  com*/
    if (convertView != null && convertView.getTag() != null) {
        holder = (ViewHolder) convertView.getTag();
    } else {
        convertView = mInflater.inflate(R.layout.list_event_item, viewGroup, false);
        holder = new ViewHolder(convertView);
        convertView.setTag(holder);
    }
    Item item = getItemInternal(i);
    final SimpleEvent event = item.getEvent();

    if (event.getIconUrl() != null) {
        App.getInstance().getPicasso().load(Const.URL_DEVELOPERS_GOOGLE_COM + event.getIconUrl())
                .into(holder.icon);
    } else {
        holder.icon.setImageResource(mDefaultIcon);
    }

    holder.eventTitle.setText(event.getTitle());

    final LocalDateTime dateTime = event.getStart().toLocalDateTime();
    holder.eventDate.setText(dateTime
            .toString(DateTimeFormat.patternForStyle("S-", mContext.getResources().getConfiguration().locale)));
    holder.eventTime.setText(dateTime
            .toString(DateTimeFormat.patternForStyle("-S", mContext.getResources().getConfiguration().locale)));

    holder.eventLocation.setText(event.getLocation());

    if (event.getStart().isBefore(DateTime.now())) {
        holder.past.setVisibility(View.VISIBLE);
    } else {
        holder.past.setVisibility(View.GONE);
    }

    // That item will contain a special property that tells if it was freshly retrieved
    if (!item.isConsumed()) {
        item.setConsumed(true);
        // In which case we magically instantiate our effect and launch it directly on the view
        Animation animation = AnimationUtils.makeInChildBottomAnimation(mContext);
        convertView.startAnimation(animation);
    }

    return convertView;
}

From source file:org.gdg.frisbee.android.eventseries.EventAdapter.java

License:Apache License

@Override
public View getView(int i, View convertView, ViewGroup viewGroup) {
    ViewHolder holder;/*from   w ww  .  j  a v a2  s.  c  o  m*/
    if (convertView != null && convertView.getTag() != null) {
        holder = (ViewHolder) convertView.getTag();
    } else {
        convertView = mInflater.inflate(R.layout.list_event_item, viewGroup, false);
        holder = new ViewHolder(convertView);
        convertView.setTag(holder);
    }
    Item item = getItemInternal(i);
    final SimpleEvent event = item.getEvent();

    if (event.getIconUrl() != null) {
        picasso.load(Const.URL_DEVELOPERS_GOOGLE_COM + event.getIconUrl()).into(holder.icon);
    } else {
        holder.icon.setImageResource(mDefaultIcon);
    }

    holder.eventTitle.setText(event.getTitle());

    final LocalDateTime dateTime = event.getStart().toLocalDateTime();
    Locale locale = context.getResources().getConfiguration().locale;
    holder.eventDate.setText(dateTime.toString(DateTimeFormat.patternForStyle("S-", locale)));
    holder.eventTime.setText(dateTime.toString(DateTimeFormat.patternForStyle("-S", locale)));

    holder.eventLocation.setText(event.getLocation());

    if (event.getStart().isBefore(DATETIME_NOW)) {
        holder.past.setVisibility(View.VISIBLE);
    } else {
        holder.past.setVisibility(View.GONE);
    }

    // That item will contain a special property that tells if it was freshly retrieved
    if (!item.isConsumed()) {
        item.setConsumed(true);
        // In which case we magically instantiate our effect and launch it directly on the view
        Animation animation = AnimationUtils.makeInChildBottomAnimation(context);
        convertView.startAnimation(animation);
    }

    return convertView;
}

From source file:org.gnucash.android.ui.chart.BarChartActivity.java

License:Apache License

/**
 * Returns a data object that represents a user data of the specified account types
 * @param accountType account's type which will be displayed
 * @return a {@code BarData} instance that represents a user data
 *///  w  w w  .  j  a va 2  s.  co m
private BarData getData(AccountType accountType) {
    List<BarEntry> values = new ArrayList<>();
    List<String> labels = new ArrayList<>();
    List<Integer> colors = new ArrayList<>();
    Map<String, Integer> accountToColorMap = new LinkedHashMap<>();
    List<String> xValues = new ArrayList<>();
    LocalDateTime tmpDate = new LocalDateTime(getStartDate(accountType).toDate().getTime());
    for (int i = 0; i <= Months.monthsBetween(getStartDate(accountType), getEndDate(accountType))
            .getMonths(); i++) {
        long start = tmpDate.dayOfMonth().withMinimumValue().millisOfDay().withMinimumValue().toDate()
                .getTime();
        long end = tmpDate.dayOfMonth().withMaximumValue().millisOfDay().withMaximumValue().toDate().getTime();
        List<Float> stack = new ArrayList<>();
        for (Account account : mAccountsDbAdapter.getSimpleAccountList()) {
            if (account.getAccountType() == accountType && !account.isPlaceholderAccount()
                    && account.getCurrency() == mCurrency) {

                double balance = mAccountsDbAdapter
                        .getAccountsBalance(Collections.singletonList(account.getUID()), start, end).asDouble();
                if (balance != 0) {
                    if (!accountToColorMap.containsKey(account.getUID())) {
                        Integer color;
                        if (mUseAccountColor) {
                            color = (account.getColorHexCode() != null)
                                    ? Color.parseColor(account.getColorHexCode())
                                    : COLORS[accountToColorMap.size() % COLORS.length];
                        } else {
                            color = COLORS[accountToColorMap.size() % COLORS.length];
                        }
                        accountToColorMap.put(account.getUID(), color);
                    }

                    stack.add((float) balance);
                    labels.add(account.getName());
                    colors.add(accountToColorMap.get(account.getUID()));
                    Log.d(TAG, accountType + tmpDate.toString(" MMMM yyyy ") + account.getName() + " = "
                            + stack.get(stack.size() - 1));
                }
            }
        }

        String stackLabels = labels.subList(labels.size() - stack.size(), labels.size()).toString();
        values.add(new BarEntry(floatListToArray(stack), i, stackLabels));

        xValues.add(tmpDate.toString(X_AXIS_PATTERN));

        tmpDate = tmpDate.plusMonths(1);
    }

    BarDataSet set = new BarDataSet(values, "");
    set.setStackLabels(labels.toArray(new String[labels.size()]));
    set.setColors(colors);

    if (set.getYValueSum() == 0) {
        mChartDataPresent = false;
        return getEmptyData();
    }
    mChartDataPresent = true;
    return new BarData(xValues, set);
}

From source file:org.gnucash.android.ui.chart.LineChartActivity.java

License:Apache License

/**
 * Returns entries which represent a user data of the specified account type
 * @param accountType account's type which user data will be processed
 * @return entries which represent a user data
 *//*  w w  w .  jav  a2 s . c  o  m*/
private List<Entry> getEntryList(AccountType accountType) {
    List<String> accountUIDList = new ArrayList<>();
    for (Account account : mAccountsDbAdapter.getSimpleAccountList()) {
        if (account.getAccountType() == accountType && !account.isPlaceholderAccount()
                && account.getCurrency() == mCurrency) {
            accountUIDList.add(account.getUID());
        }
    }

    LocalDateTime earliest = new LocalDateTime(mEarliestTimestampsMap.get(accountType));
    LocalDateTime latest = new LocalDateTime(mLatestTimestampsMap.get(accountType));
    Log.d(TAG, "Earliest " + accountType + " date " + earliest.toString("dd MM yyyy"));
    Log.d(TAG, "Latest " + accountType + " date " + latest.toString("dd MM yyyy"));
    int months = Months.monthsBetween(earliest.withDayOfMonth(1).withMillisOfDay(0),
            latest.withDayOfMonth(1).withMillisOfDay(0)).getMonths();

    int offset = getXAxisOffset(accountType);
    List<Entry> values = new ArrayList<>(months + 1);
    for (int i = 0; i < months + 1; i++) {
        long start = earliest.dayOfMonth().withMinimumValue().millisOfDay().withMinimumValue().toDate()
                .getTime();
        long end = earliest.dayOfMonth().withMaximumValue().millisOfDay().withMaximumValue().toDate().getTime();
        float balance = (float) mAccountsDbAdapter.getAccountsBalance(accountUIDList, start, end).asDouble();
        values.add(new Entry(balance, i + offset));
        Log.d(TAG, accountType + earliest.toString(" MMM yyyy") + ", balance = " + balance);
        earliest = earliest.plusMonths(1);
    }

    return values;
}

From source file:org.gnucash.android.ui.report.barchart.StackedBarChartFragment.java

License:Apache License

/**
 * Returns a data object that represents a user data of the specified account types
 * @return a {@code BarData} instance that represents a user data
 *///  ww w .  j  av  a  2 s . c o m
protected BarData getData() {
    List<BarEntry> values = new ArrayList<>();
    List<String> labels = new ArrayList<>();
    List<Integer> colors = new ArrayList<>();
    Map<String, Integer> accountToColorMap = new LinkedHashMap<>();
    List<String> xValues = new ArrayList<>();
    LocalDateTime tmpDate = new LocalDateTime(getStartDate(mAccountType).toDate().getTime());
    int count = getDateDiff(new LocalDateTime(getStartDate(mAccountType).toDate().getTime()),
            new LocalDateTime(getEndDate(mAccountType).toDate().getTime()));
    for (int i = 0; i <= count; i++) {
        long start = 0;
        long end = 0;
        switch (mGroupInterval) {
        case MONTH:
            start = tmpDate.dayOfMonth().withMinimumValue().millisOfDay().withMinimumValue().toDate().getTime();
            end = tmpDate.dayOfMonth().withMaximumValue().millisOfDay().withMaximumValue().toDate().getTime();

            xValues.add(tmpDate.toString(X_AXIS_MONTH_PATTERN));
            tmpDate = tmpDate.plusMonths(1);
            break;
        case QUARTER:
            int quarter = getQuarter(tmpDate);
            start = tmpDate.withMonthOfYear(quarter * 3 - 2).dayOfMonth().withMinimumValue().millisOfDay()
                    .withMinimumValue().toDate().getTime();
            end = tmpDate.withMonthOfYear(quarter * 3).dayOfMonth().withMaximumValue().millisOfDay()
                    .withMaximumValue().toDate().getTime();

            xValues.add(String.format(X_AXIS_QUARTER_PATTERN, quarter, tmpDate.toString(" YY")));
            tmpDate = tmpDate.plusMonths(3);
            break;
        case YEAR:
            start = tmpDate.dayOfYear().withMinimumValue().millisOfDay().withMinimumValue().toDate().getTime();
            end = tmpDate.dayOfYear().withMaximumValue().millisOfDay().withMaximumValue().toDate().getTime();

            xValues.add(tmpDate.toString(X_AXIS_YEAR_PATTERN));
            tmpDate = tmpDate.plusYears(1);
            break;
        }
        List<Float> stack = new ArrayList<>();
        for (Account account : mAccountsDbAdapter.getSimpleAccountList()) {
            if (account.getAccountType() == mAccountType && !account.isPlaceholderAccount()
                    && account.getCommodity().equals(mCommodity)) {

                double balance = mAccountsDbAdapter
                        .getAccountsBalance(Collections.singletonList(account.getUID()), start, end).asDouble();
                if (balance != 0) {
                    stack.add((float) balance);

                    String accountName = account.getName();
                    while (labels.contains(accountName)) {
                        if (!accountToColorMap.containsKey(account.getUID())) {
                            for (String label : labels) {
                                if (label.equals(accountName)) {
                                    accountName += " ";
                                }
                            }
                        } else {
                            break;
                        }
                    }
                    labels.add(accountName);

                    if (!accountToColorMap.containsKey(account.getUID())) {
                        Integer color;
                        if (mUseAccountColor) {
                            color = (account.getColor() != Account.DEFAULT_COLOR) ? account.getColor()
                                    : COLORS[accountToColorMap.size() % COLORS.length];
                        } else {
                            color = COLORS[accountToColorMap.size() % COLORS.length];
                        }
                        accountToColorMap.put(account.getUID(), color);
                    }
                    colors.add(accountToColorMap.get(account.getUID()));

                    Log.d(TAG, mAccountType + tmpDate.toString(" MMMM yyyy ") + account.getName() + " = "
                            + stack.get(stack.size() - 1));
                }
            }
        }

        String stackLabels = labels.subList(labels.size() - stack.size(), labels.size()).toString();
        values.add(new BarEntry(floatListToArray(stack), i, stackLabels));
    }

    BarDataSet set = new BarDataSet(values, "");
    set.setDrawValues(false);
    set.setStackLabels(labels.toArray(new String[labels.size()]));
    set.setColors(colors);

    if (set.getYValueSum() == 0) {
        mChartDataPresent = false;
        return getEmptyData();
    }
    mChartDataPresent = true;
    return new BarData(xValues, set);
}

From source file:org.gnucash.android.ui.report.BarChartFragment.java

License:Apache License

/**
 * Returns a data object that represents a user data of the specified account types
 * @return a {@code BarData} instance that represents a user data
 *///from w  w  w  . j  av  a 2s. c  om
private BarData getData() {
    List<BarEntry> values = new ArrayList<>();
    List<String> labels = new ArrayList<>();
    List<Integer> colors = new ArrayList<>();
    Map<String, Integer> accountToColorMap = new LinkedHashMap<>();
    List<String> xValues = new ArrayList<>();
    LocalDateTime tmpDate = new LocalDateTime(getStartDate(mAccountType).toDate().getTime());
    int count = getDateDiff(new LocalDateTime(getStartDate(mAccountType).toDate().getTime()),
            new LocalDateTime(getEndDate(mAccountType).toDate().getTime()));
    for (int i = 0; i <= count; i++) {
        long start = 0;
        long end = 0;
        switch (mGroupInterval) {
        case MONTH:
            start = tmpDate.dayOfMonth().withMinimumValue().millisOfDay().withMinimumValue().toDate().getTime();
            end = tmpDate.dayOfMonth().withMaximumValue().millisOfDay().withMaximumValue().toDate().getTime();

            xValues.add(tmpDate.toString(X_AXIS_MONTH_PATTERN));
            tmpDate = tmpDate.plusMonths(1);
            break;
        case QUARTER:
            int quarter = getQuarter(tmpDate);
            start = tmpDate.withMonthOfYear(quarter * 3 - 2).dayOfMonth().withMinimumValue().millisOfDay()
                    .withMinimumValue().toDate().getTime();
            end = tmpDate.withMonthOfYear(quarter * 3).dayOfMonth().withMaximumValue().millisOfDay()
                    .withMaximumValue().toDate().getTime();

            xValues.add(String.format(X_AXIS_QUARTER_PATTERN, quarter, tmpDate.toString(" YY")));
            tmpDate = tmpDate.plusMonths(3);
            break;
        case YEAR:
            start = tmpDate.dayOfYear().withMinimumValue().millisOfDay().withMinimumValue().toDate().getTime();
            end = tmpDate.dayOfYear().withMaximumValue().millisOfDay().withMaximumValue().toDate().getTime();

            xValues.add(tmpDate.toString(X_AXIS_YEAR_PATTERN));
            tmpDate = tmpDate.plusYears(1);
            break;
        }
        List<Float> stack = new ArrayList<>();
        for (Account account : mAccountsDbAdapter.getSimpleAccountList()) {
            if (account.getAccountType() == mAccountType && !account.isPlaceholderAccount()
                    && account.getCurrency() == mCurrency) {

                double balance = mAccountsDbAdapter
                        .getAccountsBalance(Collections.singletonList(account.getUID()), start, end).asDouble();
                if (balance != 0) {
                    if (!accountToColorMap.containsKey(account.getUID())) {
                        Integer color;
                        if (mUseAccountColor) {
                            color = (account.getColorHexCode() != null)
                                    ? Color.parseColor(account.getColorHexCode())
                                    : COLORS[accountToColorMap.size() % COLORS.length];
                        } else {
                            color = COLORS[accountToColorMap.size() % COLORS.length];
                        }
                        accountToColorMap.put(account.getUID(), color);
                    }

                    stack.add((float) balance);
                    labels.add(account.getName());
                    colors.add(accountToColorMap.get(account.getUID()));
                    Log.d(TAG, mAccountType + tmpDate.toString(" MMMM yyyy ") + account.getName() + " = "
                            + stack.get(stack.size() - 1));
                }
            }
        }

        String stackLabels = labels.subList(labels.size() - stack.size(), labels.size()).toString();
        values.add(new BarEntry(floatListToArray(stack), i, stackLabels));
    }

    BarDataSet set = new BarDataSet(values, "");
    set.setDrawValues(false);
    set.setStackLabels(labels.toArray(new String[labels.size()]));
    set.setColors(colors);

    if (set.getYValueSum() == 0) {
        mChartDataPresent = false;
        return getEmptyData();
    }
    mChartDataPresent = true;
    return new BarData(xValues, set);
}