List of usage examples for android.text.format DateUtils FORMAT_CAP_AMPM
int FORMAT_CAP_AMPM
To view the source code for android.text.format DateUtils FORMAT_CAP_AMPM.
Click Source Link
From source file:Main.java
public static String formatDate(Context context, long date) { int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME; return DateUtils.formatDateTime(context, date, format_flags); }
From source file:Main.java
@SuppressWarnings("deprecation") public static String formatTimeStampString(Context context, long when, boolean fullFormat) { Time then = new Time(); then.set(when);//from w ww . j ava2 s . c o m Time now = new Time(); now.setToNow(); // Basic settings for formatDateTime() we want for all cases. int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM; // If the message is from a different year, show the date and year. if (then.year != now.year) { format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE; } else if (then.yearDay != now.yearDay) { // If it is from a different day than today, show only the date. format_flags |= DateUtils.FORMAT_SHOW_DATE; } else { // Otherwise, if the message is from today, show the time. format_flags |= DateUtils.FORMAT_SHOW_TIME; } // If the caller has asked for full details, make sure to show the date // and time no matter what we've determined above (but still make // showing // the year only happen if it is a different year from today). if (fullFormat) { format_flags |= (DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); } return DateUtils.formatDateTime(context, when, format_flags); }
From source file:com.android.mms.ui.MessageUtils.java
public static String formatTimeStampString(Context context, long when, boolean fullFormat) { Time then = new Time(); then.set(when);//from ww w .j av a 2 s . c om Time now = new Time(); now.setToNow(); // Basic settings for formatDateTime() we want for all cases. int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | /// M: Fix ALPS00419488 to show 12:00, so mark DateUtils.FORMAT_ABBREV_ALL //DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM; // If the message is from a different year, show the date and year. if (then.year != now.year) { format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE; } else if (then.yearDay != now.yearDay) { // If it is from a different day than today, show only the date. format_flags |= DateUtils.FORMAT_SHOW_DATE; } else { // Otherwise, if the message is from today, show the time. format_flags |= DateUtils.FORMAT_SHOW_TIME; } // If the caller has asked for full details, make sure to show the date // and time no matter what we've determined above (but still make showing // the year only happen if it is a different year from today). if (fullFormat) { format_flags |= (DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME); } String dateTime = sOpMessageUtilsExt.formatTimeStampString(context, when, format_flags); if (dateTime != null) { return dateTime; } return DateUtils.formatDateTime(context, when, format_flags); }
From source file:com.dwdesign.tweetings.util.Utils.java
public static String formatTimeStampString(final Context context, final long timestamp) { if (context == null) return null; final Time then = new Time(); then.set(timestamp);//from w ww .jav a 2 s.c om final Time now = new Time(); now.setToNow(); int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM; if (then.year != now.year) { format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE; } else if (then.yearDay != now.yearDay) { format_flags |= DateUtils.FORMAT_SHOW_DATE; } else { format_flags |= DateUtils.FORMAT_SHOW_TIME; } return DateUtils.formatDateTime(context, timestamp, format_flags); }
From source file:com.dwdesign.tweetings.util.Utils.java
public static String formatToLongTimeString(final Context context, final long timestamp) { if (context == null) return null; final Time then = new Time(); then.set(timestamp);// w w w. ja v a2s. c o m final Time now = new Time(); now.setToNow(); int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_CAP_AMPM; format_flags |= DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME; return DateUtils.formatDateTime(context, timestamp, format_flags); }
From source file:de.vanita5.twittnuker.util.Utils.java
@SuppressWarnings("deprecation") public static String formatTimeStampString(final Context context, final long timestamp) { if (context == null) return null; final Time then = new Time(); then.set(timestamp);//from w w w. j a v a 2 s. co m final Time now = new Time(); now.setToNow(); int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM; if (then.year != now.year) { format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE; } else if (then.yearDay != now.yearDay) { format_flags |= DateUtils.FORMAT_SHOW_DATE; } else { format_flags |= DateUtils.FORMAT_SHOW_TIME; } return DateUtils.formatDateTime(context, timestamp, format_flags); }
From source file:de.vanita5.twittnuker.util.Utils.java
@SuppressWarnings("deprecation") public static String formatToLongTimeString(final Context context, final long timestamp) { if (context == null) return null; final Time then = new Time(); then.set(timestamp);/*from www .j a va2 s. co m*/ final Time now = new Time(); now.setToNow(); int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM; format_flags |= DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME; return DateUtils.formatDateTime(context, timestamp, format_flags); }
From source file:org.mariotaku.harmony.MusicPlaybackService.java
private void startSleepTimer(long milliseconds, boolean gentle) { Calendar now = Calendar.getInstance(); mCurrentTimestamp = now.getTimeInMillis(); mStopTimestamp = mCurrentTimestamp + milliseconds; int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM; format_flags |= DateUtils.FORMAT_SHOW_TIME; String time = DateUtils.formatDateTime(this, mStopTimestamp, format_flags); CharSequence contentTitle = getString(R.string.sleep_timer_enabled); CharSequence contentText = getString(R.string.notification_sleep_timer, time); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(), 0); Notification notification = new Notification(R.drawable.ic_stat_playback, null, 0); notification.flags = Notification.FLAG_ONGOING_EVENT; notification.icon = R.drawable.ic_stat_sleeptimer; notification.setLatestEventInfo(this, contentTitle, contentText, contentIntent); mGentleSleepTimer = gentle;//from w w w .j a v a 2 s . co m mNotificationManager.notify(ID_NOTIFICATION_SLEEPTIMER, notification); mSleepTimerHandler.sendEmptyMessageDelayed(START_SLEEP_TIMER, milliseconds); final int nmin = (int) milliseconds / 60 / 1000; Toast.makeText(this, getResources().getQuantityString(R.plurals.NNNminutes_notif, nmin, nmin), Toast.LENGTH_SHORT).show(); }
From source file:org.yammp.MusicPlaybackService.java
private void startSleepTimer(long milliseconds, boolean gentle) { Calendar now = Calendar.getInstance(); mCurrentTimestamp = now.getTimeInMillis(); mStopTimestamp = mCurrentTimestamp + milliseconds; int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM; format_flags |= DateUtils.FORMAT_SHOW_TIME; String time = DateUtils.formatDateTime(this, mStopTimestamp, format_flags); CharSequence contentTitle = getString(R.string.sleep_timer_enabled); CharSequence contentText = getString(R.string.notification_sleep_timer, time); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(), 0); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setOngoing(true);/*from w w w .ja va2 s . c o m*/ builder.setSmallIcon(R.drawable.ic_stat_sleeptimer); builder.setContentIntent(contentIntent); builder.setContentTitle(contentTitle); builder.setContentText(contentText); mGentleSleepTimer = gentle; mNotificationManager.notify(ID_NOTIFICATION_SLEEPTIMER, builder.getNotification()); mSleepTimerHandler.sendEmptyMessageDelayed(START_SLEEP_TIMER, milliseconds); Toast.makeText(this, getResources().getQuantityString(R.plurals.NNNminutes_notif, Integer.valueOf((int) milliseconds / 60 / 1000), Integer.valueOf((int) milliseconds / 60 / 1000)), Toast.LENGTH_SHORT).show(); }
From source file:com.android.mms.ui.MessageUtils.java
public static String formatTimeStampStringExtend(Context context, long when) { Time then = new Time(); then.set(when);//ww w . j av a 2 s . c om Time now = new Time(); now.setToNow(); // Basic settings for formatDateTime() we want for all cases. int format_flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_CAP_AMPM; // If the message is from a different year, show the date and year. if (then.year != now.year) { format_flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE; } else if (then.yearDay != now.yearDay) { // If it is from a different day than today, show only the date. if ((now.yearDay - then.yearDay) == 1) { return context.getString(R.string.str_ipmsg_yesterday); } else { format_flags |= DateUtils.FORMAT_SHOW_DATE; } } else if ((now.toMillis(false) - then.toMillis(false)) < 60000) { return context.getString(R.string.time_now); } else { // Otherwise, if the message is from today, show the time. format_flags |= DateUtils.FORMAT_SHOW_TIME; } sOpMessageUtilsExt.formatTimeStampStringExtend(context, when, format_flags); return DateUtils.formatDateTime(context, when, format_flags); }