Example usage for java.text SimpleDateFormat getAvailableLocales

List of usage examples for java.text SimpleDateFormat getAvailableLocales

Introduction

In this page you can find the example usage for java.text SimpleDateFormat getAvailableLocales.

Prototype

public static Locale[] getAvailableLocales() 

Source Link

Document

Returns an array of all locales for which the get*Instance methods of this class can return localized instances.

Usage

From source file:com.hybris.mobile.app.commerce.adapter.OrderHistoryAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    View rowView;//from   w ww.  ja va  2  s .  c om

    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.item_order_history, parent, false);
        rowView.setTag(new OrderHistoryViewHolder(rowView, position));
    } else {
        rowView = convertView;
    }

    OrderHistoryViewHolder orderHistoryViewHolder = (OrderHistoryViewHolder) rowView.getTag();

    final OrderHistory order = getItem(position);

    if (order != null) {
        // Order Code
        if (StringUtils.isNotBlank(order.getCode())) {
            orderHistoryViewHolder.orderNumberTextView.setText(order.getCode());
        }

        // Date placed / created
        if (order.getPlaced() != null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.DATE_FORMAT_COMPLETE,
                    SimpleDateFormat.getAvailableLocales()[0]);

            orderHistoryViewHolder.orderDatePlacedTextView.setText(simpleDateFormat.format(order.getPlaced()));
        }

        // Status

        if (StringUtils.isNotBlank(order.getStatusDisplay())) {
            orderHistoryViewHolder.orderStatusTextView.setText(order.getStatusDisplay());
        }

        // Total price
        if (order.getTotal() != null) {
            orderHistoryViewHolder.orderTotalTextView.setText(order.getTotal().getFormattedValue());
        }

        // Redirecting to the order detail page when clicking on the item
        orderHistoryViewHolder.orderHistoryLayout.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intentOrderDetail = new Intent(getContext(), OrderDetailActivity.class);
                intentOrderDetail.putExtra(IntentConstants.ORDER_CODE, order.getCode());
                getContext().startActivity(intentOrderDetail);
            }
        });

    }
    return rowView;
}

From source file:com.hybris.mobile.app.commerce.fragment.OrderDetailFragment.java

private void populateOrder(Order order) {
    if (order != null) {

        mOrderDetailNumber.setText(getString(R.string.order_detail_number, order.getCode()));

        if (order.getCreated() != null) {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.DATE_FORMAT_COMPLETE,
                    SimpleDateFormat.getAvailableLocales()[0]);

            mOrderDetailDatePlaced.setText(simpleDateFormat.format(order.getCreated()));
        }//  w w w .jav a2s  .co m

        mOrderDetailSatus.setText(getString(R.string.order_detail_status, order.getStatusDisplay()));

        // fill Delivery info
        OrderHelper.createDeliverySummary(getActivity(), order);

        // fill order summary
        OrderHelper.createOrderSummary(getActivity(), order);

        mOrderProductListAdapter.clear();
        mOrderProductListAdapter.addAll(order.getDeliveryOrderGroups().get(0).getEntries());

        // Updating the list
        mOrderProductListAdapter.notifyDataSetChanged();
    }
}