List of usage examples for android.text.format DateUtils FORMAT_12HOUR
int FORMAT_12HOUR
To view the source code for android.text.format DateUtils FORMAT_12HOUR.
Click Source Link
From source file:com.massivekinetics.ow.ui.views.timepicker.TimePicker.java
@Override public void onPopulateAccessibilityEvent(AccessibilityEvent event) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) super.onPopulateAccessibilityEvent(event); int flags = DateUtils.FORMAT_SHOW_TIME; if (mIs24HourView) { flags |= DateUtils.FORMAT_24HOUR; } else {/*from ww w . j av a 2s. c o m*/ flags |= DateUtils.FORMAT_12HOUR; } mTempCalendar.set(Calendar.HOUR_OF_DAY, getCurrentHour()); mTempCalendar.set(Calendar.MINUTE, getCurrentMinute()); String selectedDateUtterance = DateUtils.formatDateTime(getContext(), mTempCalendar.getTimeInMillis(), flags); event.getText().add(selectedDateUtterance); }
From source file:com.dgsd.android.ShiftTracker.Fragment.EditShiftFragment.java
@Override public void onTimeSelected(long millis) { if (getActivity() == null) return;/* w ww . j a v a 2 s . c om*/ TextView tv = null; if (mLastTimeSelected == LastTimeSelected.START) tv = mStartTime; else if (mLastTimeSelected == LastTimeSelected.END) tv = mEndTime; else return; //O no! This should never happen! tv.setTag(millis); int flags = DateUtils.FORMAT_SHOW_TIME; if (DateFormat.is24HourFormat(getActivity())) flags |= DateUtils.FORMAT_24HOUR; else flags |= DateUtils.FORMAT_12HOUR; tv.setError(null); tv.setText(DateUtils.formatDateRange(getActivity(), millis, millis, flags)); }
From source file:com.tr4android.support.extension.picker.time.AppCompatTimePickerDelegate.java
@Override public void onPopulateAccessibilityEvent(AccessibilityEvent event) { int flags = DateUtils.FORMAT_SHOW_TIME; if (mIs24HourView) { flags |= DateUtils.FORMAT_24HOUR; } else {/*from www . j a v a2 s . c o m*/ flags |= DateUtils.FORMAT_12HOUR; } mTempCalendar.set(Calendar.HOUR_OF_DAY, getCurrentHour()); mTempCalendar.set(Calendar.MINUTE, getCurrentMinute()); String selectedDate = DateUtils.formatDateTime(mContext, mTempCalendar.getTimeInMillis(), flags); event.getText().add(selectedDate); }
From source file:com.appeaser.sublimepickerlibrary.timepicker.SublimeTimePicker.java
@Override public void onPopulateAccessibilityEvent(AccessibilityEvent event) { super.onPopulateAccessibilityEvent(event); int flags = DateUtils.FORMAT_SHOW_TIME; // The deprecation status does not show up in the documentation and // source code does not outline the alternative. // Leaving this as is for now. if (mIs24HourView) { //noinspection deprecation flags |= DateUtils.FORMAT_24HOUR; } else {//from w w w . jav a 2s. co m //noinspection deprecation flags |= DateUtils.FORMAT_12HOUR; } mTempCalendar.set(Calendar.HOUR_OF_DAY, getCurrentHour()); mTempCalendar.set(Calendar.MINUTE, getCurrentMinute()); String selectedDate = DateUtils.formatDateTime(mContext, mTempCalendar.getTimeInMillis(), flags); event.getText().add(selectedDate); }
From source file:com.dwdesign.tweetings.util.Utils.java
public static String formatSameDayTime(final Context context, final long timestamp) { if (context == null) return null; if (DateUtils.isToday(timestamp)) return DateUtils.formatDateTime(context, timestamp, DateFormat.is24HourFormat(context) ? DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_12HOUR); return DateUtils.formatDateTime(context, timestamp, DateUtils.FORMAT_SHOW_DATE); }
From source file:de.vanita5.twittnuker.util.Utils.java
@SuppressWarnings("deprecation") public static String formatSameDayTime(final Context context, final long timestamp) { if (context == null) return null; if (DateUtils.isToday(timestamp)) return DateUtils.formatDateTime(context, timestamp, DateFormat.is24HourFormat(context) ? DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_12HOUR); return DateUtils.formatDateTime(context, timestamp, DateUtils.FORMAT_SHOW_DATE); }
From source file:com.dwdesign.tweetings.util.Utils.java
public static void showErrorToast(final Context context, final String action, final Throwable t, final boolean long_message) { if (context == null) return;/* ww w .j a va 2 s.co m*/ final String message; if (t != null) { final String t_message = trimLineBreak(unescape(t.getMessage())); if (action != null) { if (t instanceof TwitterException && ((TwitterException) t).exceededRateLimitation()) { final RateLimitStatus status = ((TwitterException) t).getRateLimitStatus(); final String next_reset_time_string = DateUtils.formatDateTime(context, status.getResetTime().getTime(), DateFormat.is24HourFormat(context) ? DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_12HOUR); message = context.getString(R.string.error_message_rate_limit, action, next_reset_time_string); } else { message = context.getString(R.string.error_message_with_action, action, t_message); } } else { message = context.getString(R.string.error_message, t_message); } } else { message = context.getString(R.string.error_unknown_error); } final int length = long_message ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT; final Toast toast = Toast.makeText(context, message, length); toast.show(); }
From source file:org.mariotaku.twidere.util.Utils.java
@SuppressWarnings("deprecation") public static void showErrorToast(final Context context, final String action, final Throwable t, final boolean long_message) { if (context == null) return;/* w ww. j a v a 2 s . c o m*/ final String message; if (t != null) { t.printStackTrace(); final String t_message = trimLineBreak(t.getMessage()); if (action != null) { if (t instanceof TwitterException) { final TwitterException te = (TwitterException) t; if (te.exceededRateLimitation()) { final RateLimitStatus status = te.getRateLimitStatus(); final String next_reset_time_string = DateUtils.formatDateTime(context, status.getResetTime().getTime(), DateFormat.is24HourFormat(context) ? DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_12HOUR); message = context.getString(R.string.error_message_rate_limit, action, next_reset_time_string); } else { message = context.getString(R.string.error_message_with_action, action, t_message); } } else { message = context.getString(R.string.error_message_with_action, action, t_message); } } else { message = context.getString(R.string.error_message, t_message); } } else { message = context.getString(R.string.error_unknown_error); } final int length = long_message ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT; final Toast toast = Toast.makeText(context, message, length); toast.show(); }