List of usage examples for java.util Calendar SHORT
int SHORT
To view the source code for java.util Calendar SHORT.
Click Source Link
From source file:jp.seesaa.android.datetimepicker.date.MonthView.java
protected void drawMonthDayLabels(Canvas canvas) { int y = getMonthHeaderSize() - (MONTH_DAY_LABEL_TEXT_SIZE / 2); final float dayWidthHalf = (mWidth - mEdgePadding * 2) / (mNumDays * 2.0f); for (int i = 0; i < mNumDays; i++) { int calendarDay = (i + mWeekStart) % mNumDays; final int x = (int) ((2 * i + 1) * dayWidthHalf + mEdgePadding); mDayLabelCalendar.set(Calendar.DAY_OF_WEEK, calendarDay); canvas.drawText(//from w w w. ja v a 2s . c o m mDayLabelCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.getDefault()) .toUpperCase(Locale.getDefault()), x, y, mMonthDayLabelPaint); } }
From source file:com.appsimobile.appsii.module.appsiagenda.MonthView.java
protected String getWeekDayName(int calendarDay) { mDayLabelCalendar.set(Calendar.DAY_OF_WEEK, calendarDay); String displayName = mDayLabelCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.getDefault()); return displayName.substring(0, 1); }
From source file:com.borax12.materialdaterangepicker.date.MonthView.java
protected void drawMonthDayLabels(Canvas canvas) { int y = getMonthHeaderSize() - (MONTH_DAY_LABEL_TEXT_SIZE / 2); int dayWidthHalf = (mWidth - mEdgePadding * 2) / (mNumDays * 2); for (int i = 0; i < mNumDays; i++) { int x = (2 * i + 1) * dayWidthHalf + mEdgePadding; int calendarDay = (i + mWeekStart) % mNumDays; mDayLabelCalendar.set(Calendar.DAY_OF_WEEK, calendarDay); Locale locale = Locale.getDefault(); String localWeekDisplayName = mDayLabelCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale);/* w w w . j a v a 2 s .c o m*/ String weekString = localWeekDisplayName.toUpperCase(locale).substring(0, 1); if (locale.equals(Locale.CHINA) || locale.equals(Locale.CHINESE) || locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE)) { int len = localWeekDisplayName.length(); weekString = localWeekDisplayName.substring(len - 1, len); } if (locale.getLanguage().equals("he") || locale.getLanguage().equals("iw")) { if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) { int len = localWeekDisplayName.length(); weekString = localWeekDisplayName.substring(len - 2, len - 1); } else { // I know this is duplication, but it makes the code easier to grok by // having all hebrew code in the same block weekString = localWeekDisplayName.toUpperCase(locale).substring(0, 1); } } canvas.drawText(weekString, x, y, mMonthDayLabelPaint); } }
From source file:bioLockJ.AppController.java
/** * This method creates the sub-dir under projects by attaching date-string to the project name * unless restarting, in which case we send the most recent project with a matching name. * * @param String 2nd Java param - if restartFlag, set to existing project dir, * otherwise, build new projectDir/* ww w. j a v a2 s. c o m*/ * @throws Exception if projectDir already exists */ private static void setProjectDir(final String optionalParam) throws Exception { if (doRestart(optionalParam)) { Config.setProperty(Config.PROJECT_DIR, getRestartDir().getAbsolutePath()); } else { final String year = String.valueOf(new GregorianCalendar().get(Calendar.YEAR)); final String month = new GregorianCalendar().getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.ENGLISH); final String day = twoDigitVal(new GregorianCalendar().get(Calendar.DATE)); final File projectDir = new File(Config.requireExistingDirectory(PROJECTS_DIR).getAbsolutePath() + File.separator + Config.requireString(Config.PROJECT_NAME) + "_" + year + month + day); if (projectDir.exists()) { throw new Exception("Project already exists with today's date: " + projectDir.getAbsolutePath() + ". Set restart flag to continue failed pipeline or provide a unique value for: " + Config.PROJECT_NAME); } projectDir.mkdirs(); Config.setProperty(Config.PROJECT_DIR, projectDir.getAbsolutePath()); } }
From source file:com.borax12.materialdaterangepicker.single.date.DatePickerDialog.java
private void updateDisplay(boolean announce) { if (mDayOfWeekView != null) { if (mTitle != null) mDayOfWeekView.setText(mTitle.toUpperCase(Locale.getDefault())); else {//from www. j a va 2 s.c om mDayOfWeekView .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())); mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime())); mYearView.setText(YEAR_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); mMonthAndDayView.setContentDescription(monthAndDayText); 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.example.reedme.date.DatePickerDialog.java
private void updateDisplay(boolean announce) { if (mDayOfWeekView != null) { if (mTitle != null) mDayOfWeekView.setText(mTitle.toUpperCase(Locale.getDefault())); else {/* w w w .j av a 2s .c o m*/ mDayOfWeekView .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())); mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime())); mYearView.setText(YEAR_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); mMonthAndDayView.setContentDescription(monthAndDayText); if (announce) { flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR; String fullDateText = DateUtils.formatDateTime(getActivity(), millis, flags); Util.tryAccessibilityAnnounce(mAnimator, fullDateText); } }
From source file:com.layernet.thaidatetimepicker.date.DatePickerDialog.java
private void updateDisplay(boolean announce) { if (mDayOfWeekView != null) { if (mTitle != null) mDayOfWeekView.setText(mTitle.toUpperCase(locale)); else {/* ww w. j av a 2 s . c o m*/ mDayOfWeekView.setText( mCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, locale).toUpperCase(locale)); } } mSelectedMonthTextView.setText(mCalendar.getDisplayName(Calendar.MONTH, Calendar.SHORT, locale)); mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime())); /** thai calender edit */ int Year = mCalendar.get(Calendar.YEAR) + BUDDHIST_OFFSET; mYearView.setText(String.valueOf(Year)); /** end thai calendar edit */ // 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); mMonthAndDayView.setContentDescription(monthAndDayText + 5555); 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.jarklee.materialdatetimepicker.date.DatePickerDialog.java
private void updateDisplay(boolean announce) { if (mDayOfWeekView != null) { if (mTitle != null) mDayOfWeekView.setText(mTitle.toUpperCase(getLocale())); else {// w w w. jav a 2 s .com mDayOfWeekView.setText(mCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, getLocale()) .toUpperCase(getLocale())); } } mSelectedMonthTextView.setText( mCalendar.getDisplayName(Calendar.MONTH, Calendar.SHORT, getLocale()).toUpperCase(getLocale())); mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime())); mYearView.setText(YEAR_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); mMonthAndDayView.setContentDescription(monthAndDayText); 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:cs.umass.edu.prepare.view.activities.CalendarActivity.java
/** * Updates the details view for a particular date. * @param dateKey corresponds to the selected date. Note that the date key must have zeroed * out all fields excluding month, year and date. *//*from www . ja v a 2s. co m*/ private void updateDetails(Calendar dateKey) { TextView txtDate = (TextView) findViewById(R.id.txtDate); txtDate.setText(dayFormat.format(selectedDate.getTime()) + "\n" + selectedDate.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.getDefault())); ViewGroup insertPoint = (ViewGroup) findViewById(R.id.details); insertPoint.removeAllViews(); if (adherenceData == null) { Log.w(TAG, "Warning : No adherence data found."); } else { if (adherenceData.containsKey(dateKey)) insertDetailsForDate(dateKey, insertPoint); } }
From source file:com.kunze.androidlocaltodo.TaskListActivity.java
private void SetFriendlyDueDateText(TextView dueDateView, Calendar dueDate) { SimpleDateFormat dateFormatDisplay = new SimpleDateFormat("MM-dd-yyyy", Locale.US); Calendar now = Calendar.getInstance(); int nowDay = TaskDatabase.ConvertDateToInt(now); int dueDay = TaskDatabase.ConvertDateToInt(dueDate); int dayDiff = nowDay - dueDay; if (dayDiff == 0) { dueDateView.setText("Today"); dueDateView.setTextColor(Color.RED); } else if (dueDate.before(now)) { dueDateView.setText("+ " + dayDiff + " days!"); dueDateView.setTextColor(Color.RED); } else if (dayDiff > -7) { dueDateView.setText(dueDate.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.US)); dueDateView.setTextColor(Color.BLACK); } else if (dayDiff > -14) { dueDateView.setText("Next " + dueDate.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.US)); dueDateView.setTextColor(Color.BLACK); } else {/*from w w w. ja v a 2 s . c o m*/ dueDateView.setText(dateFormatDisplay.format(dueDate.getTime())); dueDateView.setTextColor(Color.BLACK); } }