當前位置: 首頁>>代碼示例>>Java>>正文


Java DateUtils.formatDateRange方法代碼示例

本文整理匯總了Java中android.text.format.DateUtils.formatDateRange方法的典型用法代碼示例。如果您正苦於以下問題:Java DateUtils.formatDateRange方法的具體用法?Java DateUtils.formatDateRange怎麽用?Java DateUtils.formatDateRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.text.format.DateUtils的用法示例。


在下文中一共展示了DateUtils.formatDateRange方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMonthAndYearString

import android.text.format.DateUtils; //導入方法依賴的package包/類
private String getMonthAndYearString() {
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_NO_MONTH_DAY;
    mStringBuilder.setLength(0);
    long millis = mCalendar.getTimeInMillis();
    return DateUtils.formatDateRange(getContext(), millis, millis, flags);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:7,代碼來源:SimpleMonthView.java

示例2: getMonthAndYearString

import android.text.format.DateUtils; //導入方法依賴的package包/類
/**
 * 獲取年份和月份
 *
 * @return
 */
private String getMonthAndYearString() {
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_NO_MONTH_DAY;
    mStringBuilder.setLength(0);
    long millis = mCalendar.getTimeInMillis();
    return DateUtils.formatDateRange(getContext(), millis, millis, flags);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:SimpleMonthView.java

示例3: formatTime

import android.text.format.DateUtils; //導入方法依賴的package包/類
/**
 * @param startTime The start time of a session in millis.
 * @param context The context to be used for getting the display timezone.
 * @return Formats a given startTime to the specific short time.
 *         example: 12:00 AM
 */
public static String formatTime(long startTime, Context context) {
    StringBuilder sb = new StringBuilder();
    DateUtils.formatDateRange(context, new Formatter(sb), startTime, startTime,
            DateUtils.FORMAT_SHOW_TIME,
            SettingsUtils.getDisplayTimeZone(context).getID());
    return sb.toString();
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:14,代碼來源:UIUtils.java

示例4: getMonthAndYearString

import android.text.format.DateUtils; //導入方法依賴的package包/類
private String getMonthAndYearString() {
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR
            | DateUtils.FORMAT_NO_MONTH_DAY;
    mStringBuilder.setLength(0);
    long millis = mCalendar.getTimeInMillis();
    return DateUtils.formatDateRange(getContext(), millis, millis, flags);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:8,代碼來源:SimpleMonthView.java

示例5: getMonthAndYearString

import android.text.format.DateUtils; //導入方法依賴的package包/類
private String getMonthAndYearString() {
    int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_NO_MONTH_DAY;
    mStringBuilder.setLength(0);

    long millis = mCalendar.getTimeInMillis();
    return DateUtils.formatDateRange(getContext(), millis, millis, flags);    // 지역화된 포멧으로 출력
}
 
開發者ID:yongbeam,項目名稱:AirCalendar,代碼行數:8,代碼來源:SimpleMonthView.java

示例6: scheduleToString

import android.text.format.DateUtils; //導入方法依賴的package包/類
private String scheduleToString(Schedule s) {
    if(!s.open) {
        return getContext().getString(R.string.lobby_schedule_closed);
    }
    Formatter f = new Formatter();
    DateUtils.formatDateRange(getContext(), f, s.openTime, s.openTime, DateUtils.FORMAT_SHOW_TIME, Time.TIMEZONE_UTC);
    f.format(getContext().getString(R.string.lobby_schedule_range_separator));
    DateUtils.formatDateRange(getContext(), f, s.openTime + s.duration, s.openTime + s.duration, DateUtils.FORMAT_SHOW_TIME, Time.TIMEZONE_UTC);
    return f.toString();
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:11,代碼來源:LobbyView.java

示例7: updateClosedWarning

import android.text.format.DateUtils; //導入方法依賴的package包/類
private void updateClosedWarning() {
    if (network.isOpen()) {
        layoutNetworkClosed.setVisibility(View.GONE);
    } else {
        Formatter f = new Formatter();
        DateUtils.formatDateRange(getContext(), f, network.getNextOpenTime(), network.getNextOpenTime(), DateUtils.FORMAT_SHOW_TIME, Time.TIMEZONE_UTC);
        viewNetworkClosed.setText(String.format(getString(R.string.warning_network_closed), f.toString()));
        layoutNetworkClosed.setVisibility(View.VISIBLE);
    }
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:11,代碼來源:RouteFragment.java

示例8: onBindViewHolder

import android.text.format.DateUtils; //導入方法依賴的package包/類
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    holder.mItem = mValues.get(position);
    holder.mNameView.setText(holder.mItem.name);
    if(holder.mItem.down) {

        long downMinutes = (((new Date()).getTime() / 60000) - (holder.mItem.downSince.getTime() / 60000));
        holder.mStatusDescView.setVisibility(View.VISIBLE);
        holder.mStatusDescView.setText(String.format(holder.mView.getContext().getString(R.string.frag_lines_duration), downMinutes));
        holder.mStatusView.setImageResource(R.drawable.ic_warning_white);
        setDownGradient(holder);
    } else if (holder.mItem.exceptionallyClosed) {
        setDownGradient(holder);
        Formatter f = new Formatter();
        DateUtils.formatDateRange(context, f, holder.mItem.closedUntil, holder.mItem.closedUntil, DateUtils.FORMAT_SHOW_TIME, Time.TIMEZONE_UTC);
        holder.mStatusDescView.setText(String.format(holder.mView.getContext().getString(R.string.frag_lines_until), f.toString()));
        holder.mStatusView.setImageResource(R.drawable.ic_close_white_24dp);
    } else {
        holder.mView.setBackgroundColor(holder.mItem.color);
        holder.mStatusDescView.setVisibility(View.GONE);
        holder.mStatusView.setImageResource(R.drawable.ic_done_white);
    }

    holder.mView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != mListener) {
                // Notify the active callbacks interface (the activity, if the
                // fragment is attached to one) that an item has been selected.
                mListener.onListFragmentInteraction(holder.mItem);
            }
        }
    });
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:35,代碼來源:LineRecyclerViewAdapter.java

示例9: getView

import android.text.format.DateUtils; //導入方法依賴的package包/類
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    // Make sure we have a valid convertView to start with
    final View result  = convertView == null
            ? mLayoutInflater.inflate(R.layout.call_detail_history_item, parent, false)
            : convertView;

    PhoneCallDetails details = (PhoneCallDetails) getItem(position);
    CallTypeIconsView callTypeIconView =
            (CallTypeIconsView) result.findViewById(R.id.call_type_icon);
    TextView callTypeTextView = (TextView) result.findViewById(R.id.call_type_text);
    TextView dateView = (TextView) result.findViewById(R.id.date);
    TextView durationView = (TextView) result.findViewById(R.id.duration);

    int callType = details.callTypes[0];
    callTypeIconView.clear();
    callTypeIconView.add(callType);
    
    StringBuilder typeSb = new StringBuilder();
    typeSb.append(mContext.getResources().getString(getCallTypeText(callType)));
    // If not 200, we add text for user feedback about what went wrong
    if(details.statusCode != 200) {
        typeSb.append(" - ");
        typeSb.append(details.statusCode);
        if(!TextUtils.isEmpty(details.statusText)) {
            typeSb.append(" / ");
            typeSb.append(details.statusText);
        }
    }
    callTypeTextView.setText(typeSb.toString());
    
    // Set the date.
    CharSequence dateValue = DateUtils.formatDateRange(mContext, details.date, details.date,
            DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE |
            DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_YEAR);
    dateView.setText(dateValue);
    // Set the duration
    if (callType == Calls.MISSED_TYPE) {
        durationView.setVisibility(View.GONE);
    } else {
        durationView.setVisibility(View.VISIBLE);
        durationView.setText(formatDuration(details.duration));
    }

    return result;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:48,代碼來源:CallDetailHistoryAdapter.java

示例10: refresh

import android.text.format.DateUtils; //導入方法依賴的package包/類
private void refresh(boolean requestOnlineUpdate) {
    Realm realm = Realm.getDefaultInstance();
    boolean hasTripsToConfirm = Trip.getMissingConfirmTrips(realm).size() > 0;
    realm.close();

    if (hasTripsToConfirm) {
        if (unconfirmedTripsCard.getVisibility() == View.GONE) {
            FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
            Fragment newFragment = UnconfirmedTripsFragment.newInstance(1);
            transaction.replace(R.id.unconfirmed_trips_card, newFragment);
            transaction.commitAllowingStateLoss();
            unconfirmedTripsCard.setVisibility(View.VISIBLE);
        }
    } else {
        unconfirmedTripsCard.setVisibility(View.GONE);
    }

    if (mListener == null)
        return;

    MainService m = mListener.getMainService();
    if (m == null)
        return;

    if (requestOnlineUpdate) {
        m.getLineStatusCache().updateLineStatus();
        m.getStatsCache().updateStats();
    }

    Network net = m.getNetwork(MainService.PRIMARY_NETWORK_ID);
    if (net == null) {
        networkClosedCard.setVisibility(View.GONE);
        unconfirmedTripsCard.setVisibility(View.GONE);
        m.checkForTopologyUpdates();
    } else if (net.isOpen()) {
        networkClosedCard.setVisibility(View.GONE);
    } else {
        Formatter f = new Formatter();
        DateUtils.formatDateRange(getContext(), f, net.getNextOpenTime(), net.getNextOpenTime(), DateUtils.FORMAT_SHOW_TIME, Time.TIMEZONE_UTC);
        networkClosedView.setText(String.format(getString(R.string.warning_network_closed), f.toString()));
        networkClosedCard.setVisibility(View.VISIBLE);
    }
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:44,代碼來源:HomeFragment.java

示例11: onServiceConnected

import android.text.format.DateUtils; //導入方法依賴的package包/類
@Override
public void onServiceConnected(ComponentName className,
                               IBinder service) {
    // We've bound to LocalService, cast the IBinder and get LocalService instance
    binder = (MainService.LocalBinder) service;
    mainService = binder.getService();
    locBound = true;

    Network net = mainService.getNetwork(networkId);
    Line line = net.getLine(lineId);

    String title = String.format(getString(R.string.act_line_title), line.getName());
    setTitle(title);
    getSupportActionBar().setTitle(title);
    AppBarLayout abl = (AppBarLayout) findViewById(R.id.app_bar);
    final CollapsingToolbarLayout ctl = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
    ctl.setTitle(title);

    int color = line.getColor();
    ctl.setContentScrimColor(color);
    ctl.setStatusBarScrimColor(color);
    abl.setBackgroundColor(color);

    Drawable drawable = ContextCompat.getDrawable(LineActivity.this, Util.getDrawableResourceIdForLineId(line.getId()));
    drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);

    int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 35, getResources().getDisplayMetrics());
    FrameLayout iconFrame = new FrameLayout(LineActivity.this);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(height, height);
    int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        params.setMarginEnd(margin);
    }
    params.setMargins(0, 0, margin, 0);
    iconFrame.setLayoutParams(params);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        iconFrame.setBackgroundDrawable(drawable);
    } else {
        iconFrame.setBackground(drawable);
    }
    lineIconsLayout.addView(iconFrame);

    abl.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            if (ctl.getHeight() + verticalOffset < 2.5 * ViewCompat.getMinimumHeight(ctl)) {
                lineIconsLayout.animate().alpha(0);
            } else {
                lineIconsLayout.animate().alpha(1);
            }
        }
    });

    Map<String, LineStatusCache.Status> statuses = mainService.getLineStatusCache().getLineStatus();
    if (statuses.get(line.getId()) != null &&
            statuses.get(line.getId()).down) {
        disturbancesWarningLayout.setVisibility(View.VISIBLE);
    } else {
        disturbancesWarningLayout.setVisibility(View.GONE);
    }

    LinearLayout closedLayout = (LinearLayout) findViewById(R.id.closed_info_layout);
    if (line.isExceptionallyClosed(new Date())) {
        TextView closedView = (TextView) findViewById(R.id.closed_info_view);
        Formatter f = new Formatter();
        DateUtils.formatDateRange(LineActivity.this, f, line.getNextOpenTime(), line.getNextOpenTime(), DateUtils.FORMAT_SHOW_TIME, Time.TIMEZONE_UTC);
        closedView.setText(String.format(getString(R.string.act_line_closed_schedule), f.toString()));


        closedLayout.setVisibility(View.VISIBLE);
    } else {
        closedLayout.setVisibility(View.GONE);
    }

    populateLineView(LineActivity.this, getLayoutInflater(), net, line, lineLayout);
}
 
開發者ID:gbl08ma,項目名稱:underlx,代碼行數:77,代碼來源:LineActivity.java


注:本文中的android.text.format.DateUtils.formatDateRange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。