Package com.ibm.icu.util

Examples of com.ibm.icu.util.Calendar.clear()


     * @return List of dates in month
     */
    private List<Integer> getDaysInMonth(int year, int month) {
        // set up calendar to first day of month
        Calendar calendar = getUtcCalendar();
        calendar.clear();
        calendar.set(year, month, 1);
       
        ArrayList<Integer> dayList = new ArrayList<Integer>(31);
       
        // lastCalendar is used to check the situation where the calendar hits
View Full Code Here


   * @return the number of days in "until-now"
   */
  private static int dayDifference(final Calendar until) {
    Calendar nowCal = (Calendar) until.clone();
    Date nowDate = new Date(System.currentTimeMillis());
    nowCal.clear();
    nowCal.setTime(nowDate);
    int dayDiff = until.get(Calendar.JULIAN_DAY) - nowCal.get(Calendar.JULIAN_DAY);
    return dayDiff;
  }

View Full Code Here

     * @return the number of days in "until-now"
     */
    private static int dayDifference(Calendar until) {
        Calendar nowCal = (Calendar)until.clone();
        Date nowDate = new Date(System.currentTimeMillis());
        nowCal.clear();
        nowCal.setTime(nowDate);
        int dayDiff = until.get(Calendar.JULIAN_DAY) - nowCal.get(Calendar.JULIAN_DAY);
        return dayDiff;
    }
   
View Full Code Here

     * @return the number of days in "until-now"
     */
    private static int dayDifference(Calendar until) {
        Calendar nowCal = (Calendar)until.clone();
        Date nowDate = new Date(System.currentTimeMillis());
        nowCal.clear();
        nowCal.setTime(nowDate);
        int dayDiff = until.get(Calendar.JULIAN_DAY) - nowCal.get(Calendar.JULIAN_DAY);
        return dayDiff;
    }
   
View Full Code Here

    }
    ret.setLenient(false);
    ParsePosition p = new ParsePosition(0);
    boolean illegalDateString = false;
    for (;;) {
      ret.clear();
      /*
       * First attempt: Take a full date-time format MEDIUM
       */
      DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, iLocale);
      df.parse(image, ret, p);
View Full Code Here

      df.parse(image, ret, p);
      if (p.getErrorIndex() < 0)
        break;
      if (!ret.isSet(DAY_OF_MONTH) || !ret.isSet(MONTH)) {
        //Try with SHORT format     
        ret.clear();
        df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, iLocale);
        p.setIndex(0);
        p.setErrorIndex(-1);
        df.parse(image, ret, p);
        if (!ret.isSet(DAY_OF_MONTH) || !ret.isSet(MONTH)) {  // Give up with date
View Full Code Here

        df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, iLocale);
        p.setIndex(0);
        p.setErrorIndex(-1);
        df.parse(image, ret, p);
        if (!ret.isSet(DAY_OF_MONTH) || !ret.isSet(MONTH)) {  // Give up with date
          ret.clear();
          p.setErrorIndex(0);
        }
      }
      if (ret.isSet(MINUTE))
        break;
View Full Code Here

      df = DateFormat.getTimeInstance(DateFormat.MEDIUM, iLocale);
      df.parse(image, ret, p);
      if (ret.isSet(MINUTE))
        break;
      if (ret.isSet(DAY_OF_MONTH)) { // Set back possible hour (in accordance with Lotus)
        ret.clear(HOUR);
        ret.clear(HOUR_OF_DAY);
        break;
      }
      /*
       * Left: No date found, no time found
View Full Code Here

      df.parse(image, ret, p);
      if (ret.isSet(MINUTE))
        break;
      if (ret.isSet(DAY_OF_MONTH)) { // Set back possible hour (in accordance with Lotus)
        ret.clear(HOUR);
        ret.clear(HOUR_OF_DAY);
        break;
      }
      /*
       * Left: No date found, no time found
       */
 
View Full Code Here

  /*----------------------------------------------------------------------------*/
  public Calendar parseDateToCalWithFormat(final String image, final String format, final boolean[] noDT, final boolean parseLenient) {
    Calendar ret = getInstance(iLocale);
    ret.setLenient(false);
    ParsePosition p = new ParsePosition(0);
    ret.clear();
    SimpleDateFormat sdf = new SimpleDateFormat(format, iLocale);
    sdf.parse(image, ret, p);
    boolean contDate = ret.isSet(YEAR) || ret.isSet(MONTH) || ret.isSet(DAY_OF_MONTH);
    boolean contTime = ret.isSet(HOUR_OF_DAY) || ret.isSet(HOUR) || ret.isSet(MINUTE) || ret.isSet(SECOND);
    boolean illegalDateString = !contDate && !contTime;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.