Exemple #1
0
  public static List<CalEvent> getMonthEvent(ThemeDisplay themeDisplay, EventDisplayModel evModel) {
    List<CalEvent> lstEvents = new ArrayList<CalEvent>();
    TimeZone timeZone = themeDisplay.getTimeZone();
    Locale locale = themeDisplay.getLocale();
    java.util.Calendar curCal = CalendarFactoryUtil.getCalendar(timeZone, locale);

    int curDay = curCal.get(Calendar.DAY_OF_MONTH);
    int curMonth = curCal.get(Calendar.MONTH);
    int curYear = curCal.get(Calendar.YEAR);
    int maxDayOfMonth = curCal.getActualMaximum(Calendar.DATE);

    GregorianCalendar gregCal = new GregorianCalendar();
    gregCal.set(Calendar.MONTH, curMonth);
    gregCal.set(Calendar.YEAR, curYear);

    try {
      for (int i = 1; i < maxDayOfMonth; i++) {
        List<CalEvent> tempEvents = new ArrayList<CalEvent>();
        gregCal.set(Calendar.DATE, i);
        tempEvents.addAll(
            CalEventServiceUtil.getEvents(themeDisplay.getScopeGroupId(), gregCal, new String()));
        lstEvents.addAll(tempEvents);
      }
      return lstEvents;
    } catch (PortalException e) {
      // TODO Auto-generated catch block
      _log.error(e);
      return null;
    } catch (SystemException e) {
      // TODO Auto-generated catch block
      _log.error(e);
      return null;
    }
  }
  /**
   * This method returns all events for a specified date (year, month, date)<br>
   *
   * @param year e.g. 2010
   * @param month e.g. 11 for November
   * @param date e.g. 12
   * @return Collection of all events, which are planned for the specified date.
   */
  public Collection<CalendarEvent> getAllEventsForDate(
      int year, int month, int date, TimeZone timeZone) {
    // Get all events
    Collection<CalendarEvent> events = getCalendarEvents();
    Collection<CalendarEvent> dateEvents = new ArrayList<CalendarEvent>();

    GregorianCalendar dateCompareCalendar = new GregorianCalendar(timeZone);
    dateCompareCalendar.set(GregorianCalendar.YEAR, year);
    dateCompareCalendar.set(GregorianCalendar.MONTH, month);
    dateCompareCalendar.set(GregorianCalendar.DATE, date);
    dateCompareCalendar.set(GregorianCalendar.HOUR_OF_DAY, 00);
    dateCompareCalendar =
        (GregorianCalendar) DateUtils.truncate(dateCompareCalendar, GregorianCalendar.HOUR_OF_DAY);

    Iterator<CalendarEvent> eventsIter = events.iterator();
    while (eventsIter.hasNext()) {
      CalendarEvent event = eventsIter.next();
      GregorianCalendar eventCalendar = new GregorianCalendar(timeZone);
      eventCalendar.setTimeInMillis(event.getTimestampInMillis());

      // If selected month and year equals event in collection
      if (DateUtils.isSameDay(dateCompareCalendar, eventCalendar)) {
        dateEvents.add(event);
      }
    }
    // TODO Sort per hours
    return dateEvents;
  }
  public DateTime example4() {
    GregorianCalendar cal = new GregorianCalendar();
    cal.set(1999, 0, 1, 23, 45, 32);
    cal.set(Calendar.MILLISECOND, 234);

    return buildAttributes(cal);
  }
 private void setTimeStamp(GregorianCalendar c, Date d) {
   SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
   String datum = df.format(d);
   c.set(Calendar.YEAR, 2000 + Integer.valueOf(datum.substring(1, 4)));
   c.set(Calendar.MONTH, Integer.valueOf(datum.substring(6, 7)) - 1);
   c.set(Calendar.DAY_OF_MONTH, Integer.valueOf(datum.substring(9)));
 }
  /* (non-Javadoc)
   * @see net.finmath.time.daycount.DayCountConventionInterface#getDaycountFraction(java.util.GregorianCalendar, java.util.GregorianCalendar)
   */
  @Override
  public double getDaycountFraction(Calendar startDate, Calendar endDate) {
    if (startDate.after(endDate)) return -getDaycountFraction(endDate, startDate);

    /*
     * Number of whole years between start and end. If start and end fall in the same year, this is -1 (there will be a double counting of 1 year below if start < end).
     */
    double daycountFraction = endDate.get(Calendar.YEAR) - startDate.get(Calendar.YEAR) - 1.0;

    /*
     * Fraction from start to the end of start's year
     */
    GregorianCalendar startDateNextYear = (GregorianCalendar) startDate.clone();
    startDateNextYear.set(Calendar.DAY_OF_YEAR, 1);
    startDateNextYear.add(Calendar.YEAR, 1);
    if (isCountLastDayNotFirst) startDateNextYear.add(Calendar.DAY_OF_YEAR, -1);

    daycountFraction +=
        getDaycount(startDate, startDateNextYear)
            / startDate.getActualMaximum(Calendar.DAY_OF_YEAR);

    /*
     * Fraction from beginning of end's year to end
     */
    GregorianCalendar endDateStartYear = (GregorianCalendar) endDate.clone();
    endDateStartYear.set(Calendar.DAY_OF_YEAR, 1);
    if (isCountLastDayNotFirst) endDateStartYear.add(Calendar.DAY_OF_YEAR, -1);

    daycountFraction +=
        getDaycount(endDateStartYear, endDate) / endDate.getActualMaximum(Calendar.DAY_OF_YEAR);

    return Math.max(daycountFraction, 0.0);
  }
  public void testGetLocalAllDayCalendarTime() {
    TimeZone utcTimeZone = TimeZone.getTimeZone("UTC");
    TimeZone localTimeZone = TimeZone.getTimeZone("GMT-0700");
    GregorianCalendar correctLocal = new GregorianCalendar(localTimeZone);
    correctLocal.set(2011, 2, 10, 0, 0, 0);
    long correctLocalTime = correctLocal.getTimeInMillis();

    GregorianCalendar utcCalendar = new GregorianCalendar(utcTimeZone);
    utcCalendar.set(2011, 2, 10, 12, 23, 34);
    long utcTimeMillis = utcCalendar.getTimeInMillis();
    long convertedLocalTime =
        CalendarUtilities.getLocalAllDayCalendarTime(utcTimeMillis, localTimeZone);
    // Milliseconds aren't zeroed out and may not be the same
    assertEquals(convertedLocalTime / 1000, correctLocalTime / 1000);

    localTimeZone = TimeZone.getTimeZone("GMT+0700");
    correctLocal = new GregorianCalendar(localTimeZone);
    correctLocal.set(2011, 2, 10, 0, 0, 0);
    correctLocalTime = correctLocal.getTimeInMillis();

    utcCalendar = new GregorianCalendar(utcTimeZone);
    utcCalendar.set(2011, 2, 10, 12, 23, 34);
    utcTimeMillis = utcCalendar.getTimeInMillis();
    convertedLocalTime = CalendarUtilities.getLocalAllDayCalendarTime(utcTimeMillis, localTimeZone);
    // Milliseconds aren't zeroed out and may not be the same
    assertEquals(convertedLocalTime / 1000, correctLocalTime / 1000);
  }
  public String getStyleForDate(int year, int month, int date, TimeZone timeZone) {
    String cellStyle = null;
    if (timeZone == null) {
      timeZone = getTimeZone();
    }

    GregorianCalendar dateCompareCalendar = new GregorianCalendar(timeZone);
    dateCompareCalendar.set(GregorianCalendar.YEAR, year);
    dateCompareCalendar.set(GregorianCalendar.MONTH, month);
    dateCompareCalendar.set(GregorianCalendar.DATE, date);
    dateCompareCalendar =
        (GregorianCalendar) DateUtils.truncate(dateCompareCalendar, GregorianCalendar.DATE);

    for (Entry<Long, String> entryCellStyle : getCellStyles().entrySet()) {
      GregorianCalendar cellStyleCalendar = new GregorianCalendar(timeZone);
      cellStyleCalendar.setTimeInMillis(entryCellStyle.getKey());

      // If selected month and year equals timestamp of cell style
      if (DateUtils.isSameDay(dateCompareCalendar, cellStyleCalendar)) {
        cellStyle = entryCellStyle.getValue();
      }
    }

    return cellStyle;
  }
 private void zeroOutTime(GregorianCalendar calendar) {
   calendar.set(GregorianCalendar.HOUR, 0);
   calendar.set(GregorianCalendar.MINUTE, 0);
   calendar.set(GregorianCalendar.SECOND, 0);
   calendar.set(GregorianCalendar.MILLISECOND, 0);
   calendar.set(GregorianCalendar.HOUR_OF_DAY, 0);
 }
  public DateTime example1() {
    GregorianCalendar cal = new GregorianCalendar();
    cal.set(2001, 6, 1, 3, 45, 32);
    cal.set(Calendar.MILLISECOND, 87);

    return buildAttributes(cal);
  }
Exemple #10
0
 public CMClientFixture() {
   GregorianCalendar gc = new GregorianCalendar();
   gc.set(Calendar.MONTH, 1);
   gc.set(Calendar.YEAR, 2006);
   gc.set(Calendar.DATE, 1);
   startDate = gc.getTime();
 }
  @RequestMapping(value = "/agregaRiego", method = RequestMethod.POST)
  public String agregaRiego(
      @ModelAttribute("riego") riego r, @ModelAttribute("riegos") List<riego> riegos)
      throws Exception {

    AgregaRiego nuevo = new ObjectFactory().createAgregaRiego();
    GregorianCalendar c = new GregorianCalendar();
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    String datum = df.format(r.getFecha());
    c.set(Calendar.YEAR, 2000 + Integer.valueOf(datum.substring(1, 4)));
    c.set(Calendar.MONTH, Integer.valueOf(datum.substring(6, 7)) - 1);
    c.set(Calendar.DAY_OF_MONTH, Integer.valueOf(datum.substring(9)));

    nuevo.setFechaRiego(DatatypeFactory.newInstance().newXMLGregorianCalendar(c));
    nuevo.setNombreLote(r.getNombreLote());
    nuevo.setNombreParcela(r.getNombreParcela());
    nuevo.setRfc(r.getRfc());
    nuevo.setTipoRiego(r.getTipoRiego());

    riegoService.agregaRiego(
        nuevo.getFechaRiego(),
        nuevo.getNombreLote(),
        nuevo.getNombreParcela(),
        nuevo.getRfc(),
        nuevo.getTipoRiego());
    riegos.add(r);

    return "parcelasConsulta";
  }
  public DateTime example2() {
    GregorianCalendar cal = new GregorianCalendar();
    cal.set(1901, 11, 31, 23, 59, 59);
    cal.set(Calendar.MILLISECOND, 999);

    return buildAttributes(cal);
  }
  /** @tests java.util.SimpleTimeZone#inDaylightTime(java.util.Date) */
  public void test_inDaylightTimeLjava_util_Date() {
    // Test for method boolean
    // java.util.SimpleTimeZone.inDaylightTime(java.util.Date)
    TimeZone zone = TimeZone.getTimeZone("EST");
    GregorianCalendar gc = new GregorianCalendar(1998, Calendar.JUNE, 11);
    assertFalse("Returned incorrect daylight value1", zone.inDaylightTime(gc.getTime()));
    gc = new GregorianCalendar(1998, Calendar.NOVEMBER, 11);
    assertFalse("Returned incorrect daylight value1", zone.inDaylightTime(gc.getTime()));
    gc = new GregorianCalendar(zone);
    gc.set(1999, Calendar.APRIL, 4, 1, 59, 59);
    assertTrue("Returned incorrect daylight value3", !(zone.inDaylightTime(gc.getTime())));
    Date date = new Date(gc.getTime().getTime() + 1000);
    assertFalse("Returned incorrect daylight value4", zone.inDaylightTime(date));
    gc.set(1999, Calendar.OCTOBER, 31, 1, 0, 0);
    assertTrue("Returned incorrect daylight value5", !(zone.inDaylightTime(gc.getTime())));
    date = new Date(gc.getTime().getTime() - 1000);
    assertFalse("Returned incorrect daylight value6", zone.inDaylightTime(date));

    assertTrue(
        "Returned incorrect daylight value7",
        !zone.inDaylightTime(new Date(891752400000L + 7200000 - 1)));
    assertFalse(
        "Returned incorrect daylight value8",
        zone.inDaylightTime(new Date(891752400000L + 7200000)));
    assertFalse(
        "Returned incorrect daylight value9",
        zone.inDaylightTime(new Date(909288000000L + 7200000 - 1)));
    assertTrue(
        "Returned incorrect daylight value10",
        !zone.inDaylightTime(new Date(909288000000L + 7200000)));
  }
  private static void bindTimePickerValue(final View view, final Object target, final Field f2) {

    f2.setAccessible(true);
    final GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

    DatePicker dp = (DatePicker) view;
    cal.set(Calendar.DAY_OF_MONTH, dp.getDayOfMonth());
    cal.set(Calendar.MONTH, dp.getMonth());
    cal.set(Calendar.YEAR, dp.getYear());
    try {
      f2.set(target, cal.getTime());
    } catch (Exception e) {
      Log.e("CleanDroid", e.getMessage(), e);
    }

    ((TimePicker) view)
        .setOnTimeChangedListener(
            new OnTimeChangedListener() {

              @Override
              public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
                cal.set(Calendar.HOUR_OF_DAY, hourOfDay);
                cal.set(Calendar.HOUR, hourOfDay);
                cal.set(Calendar.MINUTE, minute);
                try {
                  f2.set(target, cal.getTime());
                } catch (Exception e) {
                  Log.e("CleanDroid", e.getMessage(), e);
                }
              }
            });
  }
  private static void bindDatePickerValue(final View view, final Object target, final Field f2) {
    f2.setAccessible(true);
    final GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance();

    DatePicker dp = (DatePicker) view;
    cal.set(Calendar.DAY_OF_MONTH, dp.getDayOfMonth());
    cal.set(Calendar.MONTH, dp.getMonth());
    cal.set(Calendar.YEAR, dp.getYear());
    try {
      f2.set(target, cal.getTime());
    } catch (Exception e) {
      Log.e("CleanDroid", e.getMessage());
    }

    ((DatePicker) view)
        .init(
            dp.getYear(),
            dp.getMonth(),
            dp.getDayOfMonth(),
            new OnDateChangedListener() {

              @Override
              public void onDateChanged(
                  DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                cal.set(Calendar.MONTH, monthOfYear);
                cal.set(Calendar.YEAR, year);
                try {
                  f2.set(target, cal.getTime());
                } catch (Exception e) {
                  Log.e("CleanDroid", e.getMessage());
                }
              }
            });
  }
 public void keyReleased(KeyEvent event) {
   JTextField tf = (JTextField) event.getSource();
   while (true) {
     if (tf.getName().equals("description")) {
       this.getTimer().setDescription(tf.getText());
       break;
     }
     if (tf.getName().equals("startDate")) {
       GregorianCalendar newDate = SerFormatter.getDateFromString(tf.getText(), "dd.MM.yy");
       timer.getMainTimer().setUnformattedStartDate(newDate);
       break;
     }
     if (tf.getName().equals("startTime")) {
       GregorianCalendar newDate = SerFormatter.getDateFromString(tf.getText(), "HH:mm");
       newDate.set(Calendar.SECOND, 0);
       timer.getMainTimer().setUnformattedStartTime(newDate);
       break;
     }
     if (tf.getName().equals("stopTime")) {
       GregorianCalendar newDate = SerFormatter.getDateFromString(tf.getText(), "HH:mm");
       newDate.set(Calendar.SECOND, 0);
       timer.getMainTimer().setUnformattedStopTime(newDate);
       break;
     }
     if (tf.getName().equals("jTextFieldFilePattern")) {
       this.getTimer().setFilePattern(tf.getText());
       break;
     }
     if (tf.getName().equals("jTextFieldDirPattern")) {
       this.getTimer().setDirPattern(tf.getText());
       break;
     }
     break;
   }
 }
Exemple #17
0
  /**
   * This method should be implemented in any subclasses of this component interested in processing
   * parameters from an html post operation. The component should interogate the HttpServletRequest
   * for any parameters it is interested in and change its internal state to reflect the parms.
   *
   * @return true if this component is the one that submitted the page and false if not.
   * @param parms a HashTable containing all the parameters for the servlet.
   */
  public boolean processParms(Hashtable parms, int rowNo) throws Exception {

    Object parm = parms.get(getFullName());
    if (parm == null) return false;

    String[] command = (String[]) parm;

    if (command[0] == null || command[0].trim().equals("")) return false;

    String st[] = getLookupComponent();
    if (command[0].startsWith("changeMonth:")) {
      int monthInc = Integer.parseInt(command[0].substring(12));
      GregorianCalendar g = new GregorianCalendar(_currentYear, _currentMonth, 1);
      g.add(Calendar.MONTH, monthInc);
      CalendarMonthChangeEvent e =
          new CalendarMonthChangeEvent(
              this, _currentMonth, _currentYear, g.get(Calendar.MONTH), g.get(Calendar.YEAR));
      _calEvent = e;
      if (st != null) {
        _scrollTo = true;
        getPage().scrollToItem(getFullName() + "CalStart");
      }
    } else if (command[0].startsWith("selectDate:")) {
      String newDate = command[0].substring(11);
      int pos = newDate.indexOf("-");
      String day = newDate.substring(0, pos);
      String year = newDate.substring(pos + 1);

      int dayInt = Integer.parseInt(day);
      int yearInt = Integer.parseInt(year);

      GregorianCalendar g = new GregorianCalendar();
      g.set(Calendar.YEAR, yearInt);
      g.set(Calendar.DAY_OF_YEAR, dayInt);

      java.sql.Date d = new java.sql.Date(g.getTime().getTime());
      CalendarDateSelectedEvent e = new CalendarDateSelectedEvent(this, g, d);

      _calEvent = e;

      if (st == null) {
        _scrollTo = true;
        getPage().scrollToItem(getFullName() + "CalStart");
      } else {
        HtmlScriptGenerator gen = new HtmlScriptGenerator(getPage());
        String format = st[1];
        String dtString = null;
        if (format != null) {
          SimpleDateFormat df = new SimpleDateFormat(format);
          dtString = df.format(d);
        } else {
          dtString = d.toString();
        }
        getPage().writeScript(gen.generateReturnValueToLookupScript(dtString, ""));
      }
    }

    return true;
  }
 /**
  * give a list of two Integer : the smallest build to use and the biggest.
  *
  * @param request
  * @param builds
  * @return outList
  */
 private List<Integer> getFirstAndLastBuild(StaplerRequest request, List<?> builds) {
   List<Integer> outList = new ArrayList<Integer>(2);
   GraphConfigurationDetail graphConf =
       (GraphConfigurationDetail) createUserConfiguration(request);
   String configType = graphConf.getConfigType();
   if (configType.compareToIgnoreCase(GraphConfigurationDetail.BUILD_CONFIG) == 0) {
     if (graphConf.getBuildCount() <= 0) {
       configType = GraphConfigurationDetail.NONE_CONFIG;
     } else {
       if (builds.size() - graphConf.getBuildCount() > 0) {
         outList.add(builds.size() - graphConf.getBuildCount() + 1);
       } else {
         outList.add(1);
       }
       outList.add(builds.size());
     }
   } else if (configType.compareToIgnoreCase(GraphConfigurationDetail.DATE_CONFIG) == 0) {
     if (GraphConfigurationDetail.DEFAULT_DATE.compareTo(graphConf.getFirstDayCount()) == 0
         && GraphConfigurationDetail.DEFAULT_DATE.compareTo(graphConf.getLastDayCount()) == 0) {
       configType = GraphConfigurationDetail.NONE_CONFIG;
     } else {
       int firstBuild = -1;
       int lastBuild = -1;
       int var = builds.size();
       GregorianCalendar firstDate = null;
       GregorianCalendar lastDate = null;
       try {
         firstDate =
             GraphConfigurationDetail.getGregorianCalendarFromString(graphConf.getFirstDayCount());
         lastDate =
             GraphConfigurationDetail.getGregorianCalendarFromString(graphConf.getLastDayCount());
         lastDate.set(GregorianCalendar.HOUR_OF_DAY, 23);
         lastDate.set(GregorianCalendar.MINUTE, 59);
         lastDate.set(GregorianCalendar.SECOND, 59);
       } catch (ParseException e) {
         LOGGER.log(Level.SEVERE, "Error during the manage of the Calendar", e);
       }
       for (Iterator<?> iterator = builds.iterator(); iterator.hasNext(); ) {
         AbstractBuild<?, ?> currentBuild = (AbstractBuild<?, ?>) iterator.next();
         GregorianCalendar buildDate = new GregorianCalendar();
         buildDate.setTime(currentBuild.getTimestamp().getTime());
         if (firstDate.getTime().before(buildDate.getTime())) {
           firstBuild = var;
         }
         if (lastBuild < 0 && lastDate.getTime().after(buildDate.getTime())) {
           lastBuild = var;
         }
         var--;
       }
       outList.add(firstBuild);
       outList.add(lastBuild);
     }
   }
   if (configType.compareToIgnoreCase(GraphConfigurationDetail.NONE_CONFIG) == 0) {
     outList.add(1);
     outList.add(builds.size());
   }
   return outList;
 }
 // For the ending date, we want the end of the selected day which is
 public Date getEndDate() {
   gc.set(Calendar.DAY_OF_MONTH, (date + 1));
   gc.set(Calendar.AM_PM, Calendar.AM);
   gc.set(Calendar.HOUR, 23);
   gc.set(Calendar.MINUTE, 59);
   gc.set(Calendar.SECOND, 59);
   return (gc.getTime());
 }
 private Date getDateFinPeriodeRTT(Date date) {
   // doit correspondre au 31 decembre de l'année courante
   GregorianCalendar calendar = new GregorianCalendar();
   calendar.setTime(date);
   calendar.set(Calendar.MONTH, 11);
   calendar.set(Calendar.DATE, 31);
   return calendar.getTime();
 }
Exemple #21
0
 public static Date createDate(int year, int month, int date) {
   GregorianCalendar calendar = new GregorianCalendar();
   calendar.clear();
   calendar.set(Calendar.YEAR, year);
   calendar.set(Calendar.MONTH, month - 1);
   calendar.set(Calendar.DAY_OF_MONTH, date);
   return calendar.getTime();
 }
 public void onDateSet(
     DatePicker view, int selectedYear, int selectedMonth, int selectedDay) {
   GregorianCalendar newCal = new GregorianCalendar();
   newCal.set(Calendar.MONTH, selectedMonth);
   newCal.set(Calendar.DAY_OF_MONTH, selectedDay);
   newCal.set(Calendar.YEAR, selectedYear);
   repeatUntilDate.setText(DateUtil.monthDayYear.format(newCal.getTime()));
 }
  /**
   * Tests the parsing of an ISO8601 formatted date
   *
   * @throws Exception Forwards all exceptions to JUnit.
   */
  @Ignore("todo: Import the latest changes to enable the below test case.")
  public void itestParse() throws Exception {
    GregorianCalendar cal = new GregorianCalendar(2006, 05, 30, 23, 59, 54);
    cal.set(Calendar.MILLISECOND, 321);
    cal.setTimeZone(TimeZone.getTimeZone("UTC"));
    XMPDateTime dt = XMPDateTimeFactory.createFromCalendar(cal);
    XMPDateTime parsed = ISO8601Converter.parse("2006-06-30T23:59:54.321Z");
    assertEquals(0, dt.compareTo(parsed));

    cal.set(Calendar.MILLISECOND, 0);
    dt = XMPDateTimeFactory.createFromCalendar(cal);
    assertEquals(0, dt.compareTo(ISO8601Converter.parse("2006-06-30T23:59:54Z")));

    cal.set(Calendar.SECOND, 0);
    dt = XMPDateTimeFactory.createFromCalendar(cal);
    assertEquals(0, dt.compareTo(ISO8601Converter.parse("2006-06-30T23:59Z")));

    cal.set(Calendar.HOUR_OF_DAY, 0);
    dt = XMPDateTimeFactory.createFromCalendar(cal);
    assertEquals(0, dt.compareTo(ISO8601Converter.parse("2006-06-30T00:59Z")));

    cal.set(Calendar.MINUTE, 0);
    dt = XMPDateTimeFactory.createFromCalendar(cal);
    assertEquals(0, dt.compareTo(ISO8601Converter.parse("2006-06-30T00:00Z")));

    // Issue reported by S7, dates w/o timezone have to be accepted
    // toDo: Import latest version to run the following test
    // dt = ISO8601Converter.parse("2006-10-13T17:45:26.16");
    // assertEquals("2006-10-13T17:45:26.16", dt.toString());

    dt = ISO8601Converter.parse("2006-10-13T17:45:26.16Z");
    assertEquals("2006-10-13T17:45:26.16Z", dt.toString());

    dt = ISO8601Converter.parse("2006-10-13T17:45:26");
    assertEquals("2006-10-13T17:45:26", dt.toString());

    dt = ISO8601Converter.parse("2006-10-13T17:45:26+5:30");
    assertEquals("2006-10-13T17:45:26+05:30", dt.toString());

    dt = ISO8601Converter.parse("2006-10-13T17:45");
    assertEquals("2006-10-13T17:45", dt.toString());

    dt = ISO8601Converter.parse("2006-10-13T17:45-06");
    assertEquals("2006-10-13T17:45-06:00", dt.toString());

    dt = ISO8601Converter.parse("2006-10-13T17");
    assertEquals("2006-10-13T17:00", dt.toString());

    dt = ISO8601Converter.parse("2006-10-13T17Z");
    assertEquals("2006-10-13T17:00Z", dt.toString());

    dt = ISO8601Converter.parse("2006-10-13T17-03:00");
    assertEquals("2006-10-13T17:00-03:00", dt.toString());

    dt = ISO8601Converter.parse("2006-10-13");
    assertEquals("2006-10-13", dt.toString());
  }
 public void test_toLocalTime_endOfDay() {
   GregorianCalendar gcal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
   gcal.set(2008, 0, 1, 23, 59, 59);
   gcal.set(Calendar.MILLISECOND, 0);
   for (int i = 0; i < 500; i++) {
     LocalTime test = gcal.toLocalTime();
     assertEquals(test.toNanoOfDay(), (24L * 60L * 60L - 1L) * 1000000000L);
     gcal.add(Calendar.DATE, 1);
   }
 }
 public void test_toLocalTime_variableOffset() {
   GregorianCalendar gcal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris"));
   gcal.set(2008, 0, 1, 0, 0, 0);
   gcal.set(Calendar.MILLISECOND, 0);
   for (int i = 0; i < 500; i++) {
     LocalTime test = gcal.toLocalTime();
     assertEquals(test.toNanoOfDay(), 0);
     gcal.add(Calendar.DATE, 1);
   }
 }
 private GregorianCalendar completionDate() {
   final GregorianCalendar completionDate = new GregorianCalendar();
   completionDate.setTimeZone(TimeZone.getTimeZone("UTC"));
   completionDate.set(Calendar.YEAR, 2013);
   completionDate.set(Calendar.MONTH, 11);
   completionDate.set(Calendar.DAY_OF_MONTH, 15);
   completionDate.set(Calendar.HOUR_OF_DAY, 16);
   completionDate.set(Calendar.MINUTE, 05);
   completionDate.set(Calendar.SECOND, 16);
   return completionDate;
 }
 private Date getDateDebutPeriodeConges(Date date) {
   // doit correspondre au 1 juin de l'année courante ou de l'année précédente si date < mois juin
   GregorianCalendar calendar = new GregorianCalendar();
   calendar.setTime(date);
   if (calendar.get(Calendar.MONTH) < 5) {
     calendar.add(Calendar.YEAR, -1);
   }
   calendar.set(Calendar.MONTH, 5);
   calendar.set(Calendar.DATE, 1);
   return calendar.getTime();
 }
 private GregorianCalendar getCreationDate() {
   final GregorianCalendar creationDate = new GregorianCalendar();
   creationDate.setTimeZone(TimeZone.getTimeZone("UTC"));
   creationDate.set(Calendar.YEAR, 2013);
   creationDate.set(Calendar.MONTH, 11);
   creationDate.set(Calendar.DAY_OF_MONTH, 15);
   creationDate.set(Calendar.HOUR_OF_DAY, 14);
   creationDate.set(Calendar.MINUTE, 20);
   creationDate.set(Calendar.SECOND, 02);
   return creationDate;
 }
 public void test_toOffsetTime_fixedOffset() {
   GregorianCalendar gcal = new GregorianCalendar(TimeZone.getTimeZone("GMT+12:00"));
   gcal.set(2008, 0, 1, 0, 0, 0);
   gcal.set(Calendar.MILLISECOND, 0);
   for (int i = 0; i < 500; i++) {
     OffsetTime test = gcal.toOffsetTime();
     assertEquals(test.toLocalTime().toNanoOfDay(), 0);
     assertEquals(test.getOffset().getID(), "+12:00");
     gcal.add(Calendar.DATE, 1);
   }
 }
 /**
  * Get the expected time in nanosecs at the end of the trace, after refreshing.
  *
  * @return the expected time in nanosecs at the end of the trace
  */
 protected long getExpectedEndTimeStamp() {
   Date date = new Date((fNbWrittenEvents - 1) * SECOND_TO_MILLISECOND);
   // Syslog fills in the year when parsing so we have to do it for the
   // expected time stamp as well
   GregorianCalendar calendar = new GregorianCalendar();
   calendar.setTime(date);
   calendar.set(Calendar.YEAR, CURRENT.get(Calendar.YEAR));
   if (calendar.after(CURRENT)) {
     calendar.set(Calendar.YEAR, CURRENT.get(Calendar.YEAR) - 1);
   }
   return calendar.getTimeInMillis() * MICROSECOND_TO_NANOSECOND;
 }