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