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


Java Calendar.PM屬性代碼示例

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


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

示例1: updateAmPmControl

private void updateAmPmControl() {
    if (is24Hour()) {
        if (mAmPmSpinner != null) {
            mAmPmSpinner.setVisibility(View.GONE);
        } else {
            mAmPmButton.setVisibility(View.GONE);
        }
    } else {
        int index = mIsAm ? Calendar.AM : Calendar.PM;
        if (mAmPmSpinner != null) {
            mAmPmSpinner.setValue(index);
            mAmPmSpinner.setVisibility(View.VISIBLE);
        } else {
            mAmPmButton.setText(mAmPmStrings[index]);
            mAmPmButton.setVisibility(View.VISIBLE);
        }
    }
    mDelegator.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:19,代碼來源:TimePickerSpinnerDelegate.java

示例2: formatDte

public static String formatDte(String date) {
    SimpleDateFormat sdt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault());
    try {
        Date dt = sdt.parse(date);
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(dt.getTime());
        int y = calendar.get(Calendar.YEAR)-2000;
        int m = calendar.get(Calendar.MONTH)+1;
        int d = calendar.get(Calendar.DAY_OF_MONTH);
        int hr = calendar.get(Calendar.HOUR_OF_DAY);
        int min = calendar.get(Calendar.MINUTE);
        String time = "AM";
        if (calendar.get(Calendar.AM_PM) == Calendar.PM) { time = "PM"; }
        String day  = String.valueOf(d);
        String month = String.valueOf(m);
        String minute = String.valueOf(min);
        if (d < 10) { day  = "0"+day;  }
        if (m < 10) { month = "0"+month; }
        if (min < 10) { minute = "0"+minute; }
        return month+"/"+day+"/"+y+" "+hr+":"+minute+" "+time;
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return "";
}
 
開發者ID:faviotorres,項目名稱:AcopioMX,代碼行數:25,代碼來源:DateUtils.java

示例3: onTimeSet

@SuppressWarnings("WrongConstant")
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
    int hour, min;
    Calendar datetime = Calendar.getInstance();
    String am_pm = "" ;
    datetime.set(Calendar.HOUR_OF_DAY, hourOfDay);
    datetime.set(Calendar.MINUTE, minute);

    if (datetime.get(Calendar.AM_PM) == Calendar.AM)
        am_pm = "AM";
    else if (datetime.get(Calendar.AM_PM) == Calendar.PM)
        am_pm = "PM";
    hourOfDay = hourOfDay > 12 ? hourOfDay - 12 : hourOfDay;
    hour = hourOfDay > 9 ? hourOfDay : hourOfDay;
    min = minute > 9 ? minute : minute;
    timeInterface.setTime(hour, min, am_pm);
}
 
開發者ID:pawanchauhan05,項目名稱:AndroidUtility,代碼行數:17,代碼來源:AlertDialog.java

示例4: UpdateTimerValue

private void UpdateTimerValue() {
    final Calendar cal = Calendar.getInstance();
    final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
    final String timeValue = sdf.format(cal.getTime());
    if (cal.get(Calendar.AM_PM) == Calendar.PM) {
        jLabel20.setText(timeValue + " PM");
    } else {
        jLabel20.setText(timeValue + " AM");
    }
}
 
開發者ID:PanagiotisDrakatos,項目名稱:Weather-Forecast,代碼行數:10,代碼來源:MainWeatherFrame.java


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