本文整理匯總了Java中java.util.Calendar.AM屬性的典型用法代碼示例。如果您正苦於以下問題:Java Calendar.AM屬性的具體用法?Java Calendar.AM怎麽用?Java Calendar.AM使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.util.Calendar
的用法示例。
在下文中一共展示了Calendar.AM屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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);
}
示例3: ItemEntity1
public ItemEntity1(String title, String content, int flag) {
this.title = title;
this.content = content;
this.img = getImg(flag);
long currentTimeMillis = System.currentTimeMillis();
long timeMillis = currentTimeMillis - new Random().nextInt(1000 * 60 * 60 * 24 * 5);
final Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(timeMillis);
int time_flag = calendar.get(Calendar.AM_PM);
this.time = (String) DateFormat.format("HH:mm", calendar);
this.timeFlag = time_flag == Calendar.AM ? "AM" : "PM";
this.id = TextUtils.isEmpty(title) ? currentTimeMillis : MD5Util.stringToMD5(title).hashCode();
}
示例4: getBeijingNowTimeString
public static String getBeijingNowTimeString(String format) {
TimeZone timezone = TimeZone.getTimeZone("Asia/Shanghai");
Date date = new Date(currentTimeMillis());
SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.getDefault());
formatter.setTimeZone(timezone);
GregorianCalendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.setTimeZone(timezone);
String prefix = gregorianCalendar.get(Calendar.AM_PM) == Calendar.AM ? "上午" : "下午";
return prefix + formatter.format(date);
}
示例5: getNameWithDate
public static String getNameWithDate(String name, Date date, Locale locale, String timezone) {
Calendar cal;
if (locale != null && timezone != null) {
cal = GregorianCalendar.getInstance(TimeZone.getTimeZone(timezone), locale);
} else if (locale != null) {
cal = GregorianCalendar.getInstance(locale);
} else if (timezone != null) {
cal = GregorianCalendar.getInstance(TimeZone.getTimeZone(timezone));
} else {
cal = GregorianCalendar.getInstance();
}
cal.setTime(date);
String day = String.valueOf(cal.get(Calendar.DATE));
if (day.length() == 1) {
day = "0" + day;
}
String month = String.valueOf(cal.get(Calendar.MONTH) + 1);
if (month.length() == 1) {
month = "0" + month;
}
String hour = String.valueOf(cal.get(Calendar.HOUR));
if (hour.length() == 1) {
hour = "0" + hour;
}
String minute = String.valueOf(cal.get(Calendar.MINUTE));
if (minute.length() == 1) {
minute = "0" + minute;
}
return name + "_" + day + "_" + month + "_" + cal.get(Calendar.YEAR) + "_" +
hour + "_" + minute + "_" + cal.get(Calendar.SECOND) + "_" +
(cal.get(Calendar.AM_PM) == Calendar.AM ? "AM" : "PM");
}
示例6: RecentSetting
public RecentSetting (String title, String type) {
this.title = title;
this.type = type;
Calendar c = Calendar.getInstance();
this.date = addZeroOnDateTime(c.get(Calendar.MONTH) + 1) + "/" +
addZeroOnDateTime(c.get(Calendar.DATE)) + "/" +
c.get(Calendar.YEAR);
this.time = addZeroOnDateTime(c.get(Calendar.HOUR)) + ":" +
addZeroOnDateTime(c.get(Calendar.MINUTE)) + ":" +
addZeroOnDateTime(c.get(Calendar.SECOND)) + " " +
(c.get(Calendar.AM_PM) == Calendar.AM ? "AM" : "PM");
}
示例7: am
boolean am() {
return get(Calendar.AM_PM) == Calendar.AM;
}