本文整理汇总了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);
}
示例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 "";
}
示例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);
}
示例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");
}
}