Java Code Examples for java.util.Calendar.AM

The following are Jave code examples for showing how to use AM of the java.util.Calendar class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: AndroidUtility   File: AlertDialog.java   View Source Code Vote up 7 votes
@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);
}
 
Example 2
Project: DateTimePicker   File: TimePickerSpinnerDelegate.java   View Source Code Vote up 7 votes
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);
}
 
Example 3
Project: MultiTypeRecyclerViewAdapter   File: ItemEntity1.java   View Source Code Vote up 6 votes
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();
}
 
Example 4
Project: SimpleMutiTypeAdapter   File: TimeUtil.java   View Source Code Vote up 6 votes
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);
}
 
Example 5
Project: logistimo-web-service   File: LocalDateUtil.java   View Source Code Vote up 6 votes
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");
}
 
Example 6
Project: ForeverLibrary   File: TimeUtil.java   View Source Code Vote up 6 votes
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);
}
 
Example 7
Project: decoy   File: TimeUtil.java   View Source Code Vote up 6 votes
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);
}
 
Example 8
Project: enhanced-vnc-thumbnail-viewer   File: RecentSetting.java   View Source Code Vote up 6 votes
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");
}
 
Example 9
Project: RLibrary   File: TimeUtil.java   View Source Code Vote up 6 votes
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);
}
 
Example 10
Project: jaffa-framework   File: DateBase.java   View Source Code Vote up 5 votes
boolean am() {
    return get(Calendar.AM_PM) == Calendar.AM;
}