Example usage for android.text.format DateUtils formatDateTime

List of usage examples for android.text.format DateUtils formatDateTime

Introduction

In this page you can find the example usage for android.text.format DateUtils formatDateTime.

Prototype

public static String formatDateTime(Context context, long millis, int flags) 

Source Link

Document

Formats a date or a time according to the local conventions.

Usage

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);/*from w  w w.  ja v  a2  s .  co  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:com.borax12.materialdaterangepicker.single.time.RadialPickerLayout.java

/**
 * Announce the currently-selected time when launched.
 *///from ww  w .j a va  2  s .c  o  m
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
        // Clear the event's current text so that only the current time will be spoken.
        event.getText().clear();
        Calendar time = Calendar.getInstance();
        time.set(Calendar.HOUR, getHours());
        time.set(Calendar.MINUTE, getMinutes());
        time.set(Calendar.SECOND, getSeconds());
        long millis = time.getTimeInMillis();
        int flags = DateUtils.FORMAT_SHOW_TIME;
        if (mIs24HourMode) {
            flags |= DateUtils.FORMAT_24HOUR;
        }
        String timeString = DateUtils.formatDateTime(getContext(), millis, flags);
        event.getText().add(timeString);
        return true;
    }
    return super.dispatchPopulateAccessibilityEvent(event);
}

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 {/*from   w w w .j  a va  2 s. c  om*/
            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.codetroopers.betterpickers.recurrencepicker.RecurrencePickerDialogFragment.java

public void updateDialog() {
    // Interval//from  w ww . j  a  v a  2s . c  om
    // Checking before setting because this causes infinite recursion
    // in afterTextWatcher
    final String intervalStr = Integer.toString(mModel.interval);
    if (!intervalStr.equals(mInterval.getText().toString())) {
        mInterval.setText(intervalStr);
    }

    mFreqSpinner.setSelection(mModel.freq);
    mWeekGroup.setVisibility(mModel.freq == RecurrenceModel.FREQ_WEEKLY ? View.VISIBLE : View.GONE);
    mWeekGroup2.setVisibility(mModel.freq == RecurrenceModel.FREQ_WEEKLY ? View.VISIBLE : View.GONE);
    mMonthGroup.setVisibility(mModel.freq == RecurrenceModel.FREQ_MONTHLY ? View.VISIBLE : View.GONE);

    switch (mModel.freq) {
    case RecurrenceModel.FREQ_HOURLY:
        mIntervalResId = R.plurals.recurrence_interval_hourly;
        break;
    case RecurrenceModel.FREQ_DAILY:
        mIntervalResId = R.plurals.recurrence_interval_daily;
        break;

    case RecurrenceModel.FREQ_WEEKLY:
        mIntervalResId = R.plurals.recurrence_interval_weekly;
        for (int i = 0; i < 7; i++) {
            mWeekByDayButtons[i].setChecked(mModel.weeklyByDayOfWeek[i]);
        }
        break;

    case RecurrenceModel.FREQ_MONTHLY:
        mIntervalResId = R.plurals.recurrence_interval_monthly;

        if (mModel.monthlyRepeat == RecurrenceModel.MONTHLY_BY_DATE) {
            mMonthRepeatByRadioGroup.check(R.id.repeatMonthlyByNthDayOfMonth);
        } else if (mModel.monthlyRepeat == RecurrenceModel.MONTHLY_BY_NTH_DAY_OF_WEEK) {
            mMonthRepeatByRadioGroup.check(R.id.repeatMonthlyByNthDayOfTheWeek);
        }

        if (mMonthRepeatByDayOfWeekStr == null) {
            if (mModel.monthlyByNthDayOfWeek == 0) {
                mModel.monthlyByNthDayOfWeek = (mTime.monthDay + 6) / 7;
                // Since not all months have 5 weeks, we convert 5th NthDayOfWeek to
                // -1 for last monthly day of the week
                if (mModel.monthlyByNthDayOfWeek >= FIFTH_WEEK_IN_A_MONTH) {
                    mModel.monthlyByNthDayOfWeek = LAST_NTH_DAY_OF_WEEK;
                }
                mModel.monthlyByDayOfWeek = mTime.weekDay;
            }

            String[] monthlyByNthDayOfWeekStrs = mMonthRepeatByDayOfWeekStrs[mModel.monthlyByDayOfWeek];

            // TODO(psliwowski): Find a better way handle -1 indexes
            int msgIndex = mModel.monthlyByNthDayOfWeek < 0 ? FIFTH_WEEK_IN_A_MONTH
                    : mModel.monthlyByNthDayOfWeek;
            mMonthRepeatByDayOfWeekStr = monthlyByNthDayOfWeekStrs[msgIndex - 1];
            mRepeatMonthlyByNthDayOfWeek.setText(mMonthRepeatByDayOfWeekStr);
        }
        break;

    case RecurrenceModel.FREQ_YEARLY:
        mIntervalResId = R.plurals.recurrence_interval_yearly;
        break;
    }
    updateIntervalText();
    updateDoneButtonState();

    mEndSpinner.setSelection(mModel.end);
    if (mModel.end == RecurrenceModel.END_BY_DATE) {
        final String dateStr = DateUtils.formatDateTime(getActivity(), mModel.endDate.toMillis(false),
                DateUtils.FORMAT_NUMERIC_DATE);
        mEndDateTextView.setText(dateStr);
    } else {
        if (mModel.end == RecurrenceModel.END_BY_COUNT) {
            // Checking before setting because this causes infinite
            // recursion
            // in afterTextWatcher
            final String countStr = Integer.toString(mModel.endCount);
            if (!countStr.equals(mEndCount.getText().toString())) {
                mEndCount.setText(countStr);
            }
        }
    }
}

From source file:com.mojtaba.materialdatetimepicker.time.RadialPickerLayout.java

/**
 * Announce the currently-selected time when launched.
 *//*from   w ww . j a  v  a  2  s  .c  o m*/
@Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
        // Clear the event's current text so that only the current time will be spoken.
        event.getText().clear();
        Calendar time = Calendar.getInstance();
        time.set(Calendar.HOUR, getHours());
        time.set(Calendar.MINUTE, getMinutes());
        time.set(Calendar.SECOND, getSeconds());
        long millis = time.getTimeInMillis();
        int flags = DateUtils.FORMAT_SHOW_TIME;
        if (mIs24HourMode) {
            flags |= DateUtils.FORMAT_24HOUR;
        }
        String timeString = LanguageUtils
                .getPersianNumbers(DateUtils.formatDateTime(getContext(), millis, flags)); //TODO: Changed Here.
        event.getText().add(timeString);
        return true;
    }
    return super.dispatchPopulateAccessibilityEvent(event);
}

From source file:com.code44.finance.ui.dialogs.recurrencepicker.RecurrencePickerDialogFragment.java

public void updateDialog() {
    // Interval/*from  www.  j  a  v  a 2 s.  c o m*/
    // Checking before setting because this causes infinite recursion
    // in afterTextWatcher
    final String intervalStr = Integer.toString(mModel.interval);
    if (!intervalStr.equals(mInterval.getText().toString())) {
        mInterval.setText(intervalStr);
    }

    mFreqSpinner.setSelection(mModel.freq);
    mWeekGroup.setVisibility(mModel.freq == RecurrenceModel.FREQ_WEEKLY ? View.VISIBLE : View.GONE);
    mWeekGroup2.setVisibility(mModel.freq == RecurrenceModel.FREQ_WEEKLY ? View.VISIBLE : View.GONE);
    mMonthGroup.setVisibility(mModel.freq == RecurrenceModel.FREQ_MONTHLY ? View.VISIBLE : View.GONE);
    mEndGroup.setVisibility(mModel.freq != RecurrenceModel.FREQ_ONCE ? View.VISIBLE : View.GONE);

    switch (mModel.freq) {
    case RecurrenceModel.FREQ_ONCE:
        mIntervalResId = -1;
        mStartDateResId = R.string.on;
        break;

    case RecurrenceModel.FREQ_DAILY:
        mIntervalResId = R.plurals.recurrence_interval_daily;
        mStartDateResId = R.string.from;
        break;

    case RecurrenceModel.FREQ_WEEKLY:
        mIntervalResId = R.plurals.recurrence_interval_weekly;
        for (int i = 0; i < 7; i++) {
            mWeekByDayButtons[i].setChecked(mModel.weeklyByDayOfWeek[i]);
        }
        mStartDateResId = R.string.from;
        break;

    case RecurrenceModel.FREQ_MONTHLY:
        mIntervalResId = R.plurals.recurrence_interval_monthly;

        if (mModel.monthlyRepeat == RecurrenceModel.MONTHLY_BY_DATE) {
            mMonthRepeatByRadioGroup.check(R.id.repeatMonthlyByNthDayOfMonth);
        } else if (mModel.monthlyRepeat == RecurrenceModel.MONTHLY_BY_NTH_DAY_OF_WEEK) {
            mMonthRepeatByRadioGroup.check(R.id.repeatMonthlyByNthDayOfTheWeek);
        }

        if (mMonthRepeatByDayOfWeekStr == null) {
            if (mModel.monthlyByNthDayOfWeek == 0) {
                mModel.monthlyByNthDayOfWeek = (mTime.monthDay + 6) / 7;
                // Since not all months have 5 weeks, we convert 5th NthDayOfWeek to
                // -1 for last monthly day of the week
                if (mModel.monthlyByNthDayOfWeek >= FIFTH_WEEK_IN_A_MONTH) {
                    mModel.monthlyByNthDayOfWeek = LAST_NTH_DAY_OF_WEEK;
                }
                mModel.monthlyByDayOfWeek = mTime.weekDay;
            }

            String[] monthlyByNthDayOfWeekStrs = mMonthRepeatByDayOfWeekStrs[mModel.monthlyByDayOfWeek];

            // TODO(psliwowski): Find a better way handle -1 indexes
            int msgIndex = mModel.monthlyByNthDayOfWeek < 0 ? FIFTH_WEEK_IN_A_MONTH
                    : mModel.monthlyByNthDayOfWeek;
            mMonthRepeatByDayOfWeekStr = monthlyByNthDayOfWeekStrs[msgIndex - 1];
            mRepeatMonthlyByNthDayOfWeek.setText(mMonthRepeatByDayOfWeekStr);
        }
        mStartDateResId = R.string.from;
        break;

    case RecurrenceModel.FREQ_YEARLY:
        mIntervalResId = R.plurals.recurrence_interval_yearly;
        mStartDateResId = R.string.from;
        break;
    }
    updateIntervalText();
    updateStartDateText();
    updateDoneButtonState();

    final String startDateStr = DateUtils.formatDateTime(getActivity(), mModel.startDate.toMillis(false),
            DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_YEAR);
    mStartDateTextView.setText(startDateStr);

    mEndSpinner.setSelection(mModel.end);
    if (mModel.end == RecurrenceModel.END_BY_DATE) {
        final String endDateStr = DateUtils.formatDateTime(getActivity(), mModel.endDate.toMillis(false),
                DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_SHOW_YEAR);
        mEndDateTextView.setText(endDateStr);
    } else {
        if (mModel.end == RecurrenceModel.END_BY_COUNT) {
            // Checking before setting because this causes infinite
            // recursion
            // in afterTextWatcher
            final String countStr = Integer.toString(mModel.endCount);
            if (!countStr.equals(mEndCount.getText().toString())) {
                mEndCount.setText(countStr);
            }
        }
    }
}

From source file:org.uguess.android.sysinfo.ApplicationManager.java

void handleAction(final AppInfoHolder ai, int action) {
    Activity ctx = getActivity();//  ww  w . j  a  v a 2 s  . c  o  m
    String pkgName = ai.appInfo.packageName;

    switch (action) {
    case ACTION_MENU:

        OnClickListener listener = new OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();

                // bypass the 'showMenu' action offset
                int action = which + 1;

                handleAction(ai, action);
            }
        };

        new AlertDialog.Builder(ctx).setTitle(R.string.actions)
                .setItems(new CharSequence[] { getString(R.string.manage), getString(R.string.run),
                        getString(R.string.search_market), getString(R.string.details) }, listener)
                .create().show();

        break;
    case ACTION_MANAGE:

        Intent it = new Intent(Intent.ACTION_VIEW);

        it.setClassName("com.android.settings", //$NON-NLS-1$
                "com.android.settings.InstalledAppDetails"); //$NON-NLS-1$
        it.putExtra("com.android.settings.ApplicationPkgName", pkgName); //$NON-NLS-1$
        // this is for Froyo
        it.putExtra("pkg", pkgName); //$NON-NLS-1$

        List<ResolveInfo> acts = ctx.getPackageManager().queryIntentActivities(it, 0);

        if (acts.size() > 0) {
            startActivity(it);
        } else {
            // for ginger bread
            it = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", //$NON-NLS-1$
                    Uri.fromParts("package", pkgName, null)); //$NON-NLS-1$

            acts = ctx.getPackageManager().queryIntentActivities(it, 0);

            if (acts.size() > 0) {
                startActivity(it);
            } else {
                Log.d(ApplicationManager.class.getName(), "Failed to resolve activity for InstalledAppDetails"); //$NON-NLS-1$
            }
        }

        break;
    case ACTION_LAUNCH:

        if (!pkgName.equals(ctx.getPackageName())) {
            it = new Intent("android.intent.action.MAIN"); //$NON-NLS-1$
            it.addCategory(Intent.CATEGORY_LAUNCHER);

            acts = ctx.getPackageManager().queryIntentActivities(it, 0);

            if (acts != null) {
                boolean started = false;

                for (int i = 0, size = acts.size(); i < size; i++) {
                    ResolveInfo ri = acts.get(i);

                    if (pkgName.equals(ri.activityInfo.packageName)) {
                        it.setClassName(ri.activityInfo.packageName, ri.activityInfo.name);

                        it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

                        try {
                            startActivity(it);

                            started = true;

                        } catch (Exception e) {
                            Log.e(ApplicationManager.class.getName(), "Cannot start activity: " + pkgName, //$NON-NLS-1$
                                    e);
                        }

                        break;
                    }
                }

                if (!started) {
                    Util.shortToast(ctx, R.string.run_failed);
                }
            }
        }

        break;
    case ACTION_SEARCH:

        it = new Intent(Intent.ACTION_VIEW);

        it.setData(Uri.parse("market://search?q=pname:" + pkgName)); //$NON-NLS-1$

        it = Intent.createChooser(it, null);

        startActivity(it);

        break;
    case ACTION_DETAILS:

        ApplicationInfo appInfo = ai.appInfo;

        String installDate;
        String fileSize;

        if (appInfo.sourceDir != null) {
            File f = new File(appInfo.sourceDir);
            installDate = DateUtils.formatDateTime(ctx, f.lastModified(),
                    DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_TIME);
            fileSize = Formatter.formatFileSize(ctx, f.length());
        } else {
            installDate = fileSize = getString(R.string.unknown);
        }

        StringBuffer sb = new StringBuffer().append("<small>") //$NON-NLS-1$
                .append(getString(R.string.pkg_name)).append(": ") //$NON-NLS-1$
                .append(appInfo.packageName).append("<br>") //$NON-NLS-1$
                .append(getString(R.string.version_code)).append(": ") //$NON-NLS-1$
                .append(ai.versionCode).append("<br>") //$NON-NLS-1$
                .append(getString(R.string.target_sdk)).append(": ") //$NON-NLS-1$
                .append(Util.getTargetSdkVersion(ctx, appInfo)).append("<br>") //$NON-NLS-1$
                .append(getString(R.string.uid)).append(": ") //$NON-NLS-1$
                .append(appInfo.uid).append("<br>") //$NON-NLS-1$
                .append(getString(R.string.file_size)).append(": ") //$NON-NLS-1$
                .append(fileSize).append("<br>") //$NON-NLS-1$
                .append(getString(R.string.public_source)).append(": ") //$NON-NLS-1$
                .append(appInfo.publicSourceDir).append("<br>") //$NON-NLS-1$
                .append(getString(R.string.source)).append(": ") //$NON-NLS-1$
                .append(appInfo.sourceDir).append("<br>") //$NON-NLS-1$
                .append(getString(R.string.data)).append(": ") //$NON-NLS-1$
                .append(appInfo.dataDir).append("<br>") //$NON-NLS-1$
                .append(getString(R.string.installed_date)).append(": ") //$NON-NLS-1$
                .append(installDate).append("<br>") //$NON-NLS-1$
                .append(getString(R.string.process)).append(": ") //$NON-NLS-1$
                .append(appInfo.processName).append("<br>") //$NON-NLS-1$
                .append(getString(R.string.app_class)).append(": ") //$NON-NLS-1$
                .append(appInfo.className == null ? "" //$NON-NLS-1$
                        : appInfo.className)
                .append("<br>") //$NON-NLS-1$
                .append(getString(R.string.task_affinity)).append(": ") //$NON-NLS-1$
                .append(appInfo.taskAffinity).append("<br>") //$NON-NLS-1$
                .append(getString(R.string.permission)).append(": ") //$NON-NLS-1$
                .append(appInfo.permission == null ? "" //$NON-NLS-1$
                        : appInfo.permission)
                .append("<br>") //$NON-NLS-1$
                .append(getString(R.string.flags)).append(": ") //$NON-NLS-1$
                .append(appInfo.flags).append("<br>") //$NON-NLS-1$
                .append(getString(R.string.enabled)).append(": ") //$NON-NLS-1$
                .append(appInfo.enabled).append("<br>") //$NON-NLS-1$
                .append(getString(R.string.manage_space_ac)).append(": ") //$NON-NLS-1$
                .append(appInfo.manageSpaceActivityName == null ? "" //$NON-NLS-1$
                        : appInfo.manageSpaceActivityName)
                .append("</small>"); //$NON-NLS-1$

        new AlertDialog.Builder(ctx).setTitle(ai.label == null ? appInfo.packageName : ai.label)
                .setNeutralButton(R.string.close, null).setMessage(Html.fromHtml(sb.toString())).create()
                .show();

        break;
    }
}

From source file:com.songcode.materialnotes.ui.NoteEditActivity.java

private String getSubTitle() {
    String dateStr = DateUtils.formatDateTime(this, mWorkingNote.getModifiedDate(), DateUtils.FORMAT_SHOW_TIME);
    if (mWorkingNote.hasClockAlert()) {
        long time = System.currentTimeMillis();
        String alertStr = "";
        if (time > mWorkingNote.getAlertDate()) {
            alertStr = getString(R.string.note_alert_expired);
        } else {//from   w w  w  .  java 2 s  . c om
            alertStr = (String) DateUtils.getRelativeTimeSpanString(mWorkingNote.getAlertDate(), time,
                    DateUtils.MINUTE_IN_MILLIS);
        }
        //emoji
        return dateStr + " | ???" + alertStr;
    }
    return dateStr;
}

From source file:cx.ring.service.LocalService.java

public void updateTextNotifications() {
    Log.d(TAG, "updateTextNotifications()");

    for (Conversation c : conversations.values()) {
        TreeMap<Long, TextMessage> texts = c.getUnreadTextMessages();
        if (texts.isEmpty() || texts.lastEntry().getValue().isNotified()) {
            continue;
        } else//ww  w.j  a va2  s . co  m
            notificationManager.cancel(c.notificationId);

        CallContact contact = c.getContact();
        if (c.notificationBuilder == null) {
            c.notificationBuilder = new NotificationCompat.Builder(getApplicationContext());
            c.notificationBuilder.setCategory(NotificationCompat.CATEGORY_MESSAGE)
                    .setPriority(NotificationCompat.PRIORITY_HIGH).setDefaults(NotificationCompat.DEFAULT_ALL)
                    .setSmallIcon(R.drawable.ic_launcher).setContentTitle(contact.getDisplayName());
        }
        NotificationCompat.Builder noti = c.notificationBuilder;
        Intent c_intent = new Intent(Intent.ACTION_VIEW).setClass(this, ConversationActivity.class)
                .setData(Uri.withAppendedPath(ConversationActivity.CONTENT_URI, contact.getIds().get(0)));
        Intent d_intent = new Intent(ACTION_CONV_READ).setClass(this, LocalService.class)
                .setData(Uri.withAppendedPath(ConversationActivity.CONTENT_URI, contact.getIds().get(0)));
        noti.setContentIntent(PendingIntent.getActivity(this, new Random().nextInt(), c_intent, 0))
                .setDeleteIntent(PendingIntent.getService(this, new Random().nextInt(), d_intent, 0));

        if (contact.getPhoto() != null) {
            Resources res = getResources();
            int height = (int) res.getDimension(android.R.dimen.notification_large_icon_height);
            int width = (int) res.getDimension(android.R.dimen.notification_large_icon_width);
            noti.setLargeIcon(Bitmap.createScaledBitmap(contact.getPhoto(), width, height, false));
        }
        if (texts.size() == 1) {
            TextMessage txt = texts.firstEntry().getValue();
            txt.setNotified(true);
            noti.setContentText(txt.getMessage());
            noti.setStyle(null);
            noti.setWhen(txt.getTimestamp());
        } else {
            NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
            for (TextMessage s : texts.values()) {
                inboxStyle.addLine(Html.fromHtml("<b>"
                        + DateUtils.formatDateTime(this, s.getTimestamp(),
                                DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_ABBREV_ALL)
                        + "</b> " + s.getMessage()));
                s.setNotified(true);
            }
            noti.setContentText(texts.lastEntry().getValue().getMessage());
            noti.setStyle(inboxStyle);
            noti.setWhen(texts.lastEntry().getValue().getTimestamp());
        }
        notificationManager.notify(c.notificationId, noti.build());
    }
}

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);
}