本文整理匯總了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");
}
}