java.text.SimpleDateFormat#getTimeInstance ( )源码实例Demo

下面列出了java.text.SimpleDateFormat#getTimeInstance ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openemm   文件: ComAdminImpl.java
@Override
public SimpleDateFormat getTimeFormat() {
	SimpleDateFormat timeFormat = (SimpleDateFormat) SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT, getLocale());
	timeFormat.setTimeZone(TimeZone.getTimeZone(getAdminTimezone()));
	timeFormat.setLenient(false);
	return timeFormat;
}
 
源代码2 项目: FairEmail   文件: Helper.java
static DateFormat getTimeInstance(Context context, int style) {
    if (context != null &&
            (style == SimpleDateFormat.SHORT || style == SimpleDateFormat.MEDIUM)) {
        Locale locale = Locale.getDefault();
        boolean is24Hour = android.text.format.DateFormat.is24HourFormat(context);
        String skeleton = (is24Hour ? "Hm" : "hm");
        if (style == SimpleDateFormat.MEDIUM)
            skeleton += "s";
        String pattern = android.text.format.DateFormat.getBestDateTimePattern(locale, skeleton);
        return new SimpleDateFormat(pattern, locale);
    } else
        return SimpleDateFormat.getTimeInstance(style);
}
 
源代码3 项目: octoandroid   文件: DateTimeConverter.java
public static String msTimeToShortTimeString(long msTime) {
    Date date = new Date(msTime);
    DateFormat df = SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
    return df.format(date);
}
 
源代码4 项目: RoomBookerMVP   文件: NewEventActivity.java
private void initDateTimeFormat() {
    simpleTimeFormat = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);
    simpleDateFormat = SimpleDateFormat.getDateInstance();
}
 
源代码5 项目: actor-platform   文件: TimeUtils.java
@Override
protected DateFormat initialValue() {
    return SimpleDateFormat.getTimeInstance(DateFormat.SHORT, Locale.getDefault());
}
 
源代码6 项目: Speculum-Android   文件: GoogleCalendarService.java
@SuppressWarnings("all")
public Observable<String> getCalendarEvents() {
    String details, title;
    Cursor cursor;
    ContentResolver contentResolver = application.getContentResolver();
    final String[] colsToQuery = new String[]{
            CalendarContract.EventsEntity.TITLE,
            CalendarContract.EventsEntity.DTSTART,
            CalendarContract.EventsEntity.DTEND,
            CalendarContract.EventsEntity.EVENT_LOCATION};

    Calendar now = Calendar.getInstance();
    SimpleDateFormat startFormat = new SimpleDateFormat(Constants.SIMPLEDATEFORMAT_DDMMYY, Locale.getDefault());
    String dateString = startFormat.format(now.getTime());
    long start = now.getTimeInMillis();

    SimpleDateFormat endFormat = new SimpleDateFormat(Constants.SIMPLEDATEFORMAT_HHMMSSDDMMYY, Locale.getDefault());
    Calendar endOfDay = Calendar.getInstance();
    Date endOfDayDate;
    try {
        endOfDayDate = endFormat.parse(Constants.END_OF_DAY_TIME + dateString);
        endOfDay.setTime(endOfDayDate);
    } catch (ParseException e) {
        Log.e(GoogleCalendarService.class.getSimpleName(), e.toString());
        throw new RuntimeException(String.format("ParseException occured: %s", e.getLocalizedMessage()));
    }

    cursor = contentResolver.query(CalendarContract.Events.CONTENT_URI, colsToQuery,
            Constants.CALENDAR_QUERY_FIRST + start + Constants.CALENDAR_QUERY_SECOND + endOfDay.getTimeInMillis() + Constants.CALENDAR_QUERY_THIRD,
            null, Constants.CALENDAR_QUERY_FOURTH);

    if (cursor != null) {
        if (cursor.getCount() > 0) {
            StringBuilder stringBuilder = new StringBuilder();
            while (cursor.moveToNext()) {
                title = cursor.getString(0);
                Calendar startTime = Calendar.getInstance();
                startTime.setTimeInMillis(cursor.getLong(1));
                Calendar endTime = Calendar.getInstance();
                endTime.setTimeInMillis(cursor.getLong(2));
                DateFormat formatter = SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
                details = formatter.format(startTime.getTime()) + " - " + formatter.format(endTime.getTime());
                if (!TextUtils.isEmpty(cursor.getString(3))) {
                    details += " " + application.getString(R.string.at) + " " + cursor.getString(3);
                }
                stringBuilder.append(title + ", " + details);
                if (!cursor.isLast()) {
                    stringBuilder.append(" | ");
                }
            }
            cursor.close();
            return Observable.just(stringBuilder.toString());
        } else {
            cursor.close();
            return Observable.just(application.getString(R.string.no_events_today));
        }
    } else {
        throw new RuntimeException(application.getString(R.string.no_events_error));
    }
}
 
源代码7 项目: Klyph   文件: DateUtil.java
private static String getFormattedTime(Date date)
{
	SimpleDateFormat timeFormat = (SimpleDateFormat) SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);

	return timeFormat.format(date);
}
 
源代码8 项目: Plumble   文件: ChannelChatFragment.java
public ChannelChatAdapter(Context context, IJumbleService service, List<IChatMessage> messages) {
    super(context, 0, new ArrayList<>(messages));
    mService = service;
    mImageGetter = new MumbleImageGetter(context);
    mDateFormat = SimpleDateFormat.getTimeInstance();
}
 
源代码9 项目: easydeviceinfo   文件: EasyConfigMod.java
/**
 * Gets formatted time.
 *
 * @return the formatted time
 */
public final String getFormattedTime() {
  DateFormat timeInstance = SimpleDateFormat.getTimeInstance();
  return timeInstance.format(Calendar.getInstance().getTime());
}
 
源代码10 项目: easydeviceinfo   文件: EasyConfigMod.java
/**
 * Gets formatted up time.
 *
 * @return the formatted up time
 */
public final String getFormattedUpTime() {
  DateFormat timeInstance = SimpleDateFormat.getTimeInstance();
  return timeInstance.format(SystemClock.uptimeMillis());
}