当前位置: 首页>>代码示例>>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;未经允许,请勿转载。