Example usage for java.util Calendar LONG

List of usage examples for java.util Calendar LONG

Introduction

In this page you can find the example usage for java.util Calendar LONG.

Prototype

int LONG

To view the source code for java.util Calendar LONG.

Click Source Link

Document

A style specifier for #getDisplayName(int,int,Locale) getDisplayName and #getDisplayNames(int,int,Locale) getDisplayNames equivalent to #LONG_FORMAT .

Usage

From source file:com.borax12.materialdaterangepicker.date.DatePickerDialog.java

private void updateDisplay(boolean announce) {
    if (mDayOfWeekView != null) {
        mDayOfWeekView/*from   w  w  w  .  ja v a 2s .c  om*/
                .setText(mCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault())
                        .toUpperCase(Locale.getDefault()));
    }

    mSelectedMonthTextView.setText(mCalendar.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.getDefault())
            .toUpperCase(Locale.getDefault()));
    mSelectedMonthTextViewEnd
            .setText(mCalendarEnd.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.getDefault())
                    .toUpperCase(Locale.getDefault()));
    mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime()));
    mSelectedDayTextViewEnd.setText(DAY_FORMAT.format(mCalendarEnd.getTime()));
    mYearView.setText(YEAR_FORMAT.format(mCalendar.getTime()));
    mYearViewEnd.setText(YEAR_FORMAT.format(mCalendarEnd.getTime()));

    // Accessibility.
    long millis = mCalendar.getTimeInMillis();
    long millisEnd = mCalendarEnd.getTimeInMillis();
    mAnimator.setDateMillis(millis);
    mAnimatorEnd.setDateMillis(millisEnd);
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR;
    String monthAndDayText = DateUtils.formatDateTime(getActivity(), millis, flags);
    String monthAndDayTextEnd = DateUtils.formatDateTime(getActivity(), millisEnd, flags);
    mMonthAndDayView.setContentDescription(monthAndDayText);
    mMonthAndDayViewEnd.setContentDescription(monthAndDayTextEnd);

    if (announce) {
        flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
        String fullDateText = DateUtils.formatDateTime(getActivity(), millis, flags);
        String fullDateTextEnd = DateUtils.formatDateTime(getActivity(), millisEnd, flags);
        Utils.tryAccessibilityAnnounce(mAnimator, fullDateText);
        Utils.tryAccessibilityAnnounce(mAnimatorEnd, fullDateTextEnd);
    }
}

From source file:com.kenmeidearu.materialdatetimepicker.date.DatePickerDialog.java

private void updateDisplay(boolean announce) {
    if (mDayOfWeekView != null) {
        if (mTitle != null)
            mDayOfWeekView.setText(mTitle.toUpperCase(Locale.getDefault()));
        else {/* w  ww .j  av a  2 s.  co m*/
            if (mCalendar != null) {
                mDayOfWeekView.setText(
                        mCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault())
                                .toUpperCase(Locale.getDefault()));
            }
        }
    }

    if (mSelectedMonthTextView != null)
        mSelectedMonthTextView
                .setText(mCalendar.getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.getDefault())
                        .toUpperCase(Locale.getDefault()));
    if (mSelectedDayTextView != null)
        mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime()));
    if (mYearView != null)
        mYearView.setText(YEAR_FORMAT.format(mCalendar.getTime()));
    setHour(mInitialTime.getHour());
    setMinute(mInitialTime.getMinute());
    setSecond(mInitialTime.getSecond());
    //mHourView.setText(HOUR_FORMAT.format(mCalendar.getTime()));

    // Accessibility.
    long millis = mCalendar.getTimeInMillis();
    mAnimator.setDateMillis(millis);
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR;
    String monthAndDayText = DateUtils.formatDateTime(getActivity(), millis, flags);
    mDayOfWeekView.setContentDescription(monthAndDayText);//tadinya month and day view

    if (announce) {
        flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
        String fullDateText = DateUtils.formatDateTime(getActivity(), millis, flags);
        Utils.tryAccessibilityAnnounce(mAnimator, fullDateText);
    }
}

From source file:com.miz.functions.MizLib.java

public static String getPrettyDate(Context context, String date) {
    if (!TextUtils.isEmpty(date)) {
        try {//  w w w. j  a  va 2 s . co m
            String[] dateArray = date.split("-");
            Calendar cal = Calendar.getInstance();
            cal.set(Integer.parseInt(dateArray[0]), Integer.parseInt(dateArray[1]) - 1,
                    Integer.parseInt(dateArray[2]));

            return MizLib
                    .toCapitalFirstChar(cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault())
                            + " " + cal.get(Calendar.YEAR));
        } catch (Exception e) { // Fall back if something goes wrong
            return date;
        }
    } else {
        return context.getString(R.string.stringNA);
    }
}