Package java.sql

Examples of java.sql.Date


            Object[] data = { (mod == 0) ? null : new BigDecimal("" + i), //$NON-NLS-1$
                              (mod == 1) ? null : new BigInteger(Integer.toString(i)),
                              (mod == 2) ? null : ((i%2 == 0) ? Boolean.FALSE: Boolean.TRUE),
                              (mod == 3) ? null : new Byte((byte)i),
                              (mod == 4) ? null : new Character((char)i),
                              (mod == 5) ? null : new Date(currentTime),
                              (mod == 6) ? null : new Double(i),
                              (mod == 7) ? null : new Float(i),
                              (mod == 8) ? null : new Integer(i),
                              (mod == 9) ? null : new Long(i),
                              (mod == 10) ? null : new Short((short)i),
View Full Code Here


        stat.execute("CREATE TABLE TEST(ID INT, D DATE, T TIME, TS TIMESTAMP)");
        stat.execute("INSERT INTO TEST VALUES(1, '2001-01-01', '20:00:00', '2002-02-02 22:22:22.2')");
        stat.execute("INSERT INTO TEST VALUES(1, '2001-01-01', '20:00:00', '2002-02-02 22:22:22.2')");
        ResultSet rs = stat.executeQuery("SELECT * FROM TEST");
        rs.next();
        Date d1 = rs.getDate("D");
        Time t1 = rs.getTime("T");
        Timestamp ts1 = rs.getTimestamp("TS");
        rs.next();
        Date d2 = rs.getDate("D");
        Time t2 = rs.getTime("T");
        Timestamp ts2 = rs.getTimestamp("TS");
        assertTrue(ts1 != ts2);
        assertTrue(d1 != d2);
        assertTrue(t1 != t2);
View Full Code Here

         recurrenceVO.fillRecurrenceHashMap();

         HashMap recurrenceRuleMap = recurrenceVO.getRecurrenceHM();
         if (recurrenceRuleMap != null && recurrenceRuleMap.size() > 0)
         {
           Date recurrStartDate = (Date)activityRecord.get("startdate");
           // For very long recurrences we only need to calculate out 18 months before of the
           // passedStartDate otherwise we spend all our time calculating recurring tasks.
           Calendar compareCalendar = (Calendar)passedStartDate.clone();
           compareCalendar.add(Calendar.MONTH, -18);
           Date compareDate = new Date(compareCalendar.getTimeInMillis());
           if (recurrStartDate.before(compareDate))
           {
             recurrStartDate = compareDate;
           }

           GregorianCalendar recurringStartDate = new GregorianCalendar(TimeZone.getTimeZone("EST"));
           if (recurrStartDate != null)
           {
             recurringStartDate.setTime(recurrStartDate);
             recurringStartDate.set(Calendar.HOUR, activityRecordStart.get(Calendar.HOUR));
             recurringStartDate.set(Calendar.MINUTE, activityRecordStart.get(Calendar.MINUTE));
             recurringStartDate.set(Calendar.AM_PM, activityRecordStart.get(Calendar.AM_PM));
           }

           Date recurrEndDate = (Date)activityRecord.get("Until");
           // if there is no end date (the recurrence is open ended)
           // then coerce it to the passed in end date, for calculation purposes
           // Also for very long recurrences we only need to calculate out 2 months ahead of the
           // passedEndDate otherwise we spend all our time calculating recurring tasks.
           compareCalendar = (Calendar)passedEndDate.clone();
           compareCalendar.add(Calendar.MONTH, 2);
           compareDate = new Date(compareCalendar.getTimeInMillis());
           if (recurrEndDate == null || recurrEndDate.after(compareDate))
           {
             recurrEndDate = compareDate;
           }

           // get an RFC 2445 compliant recurrance rule string.
View Full Code Here

    }
   
    // case 2458
    @Test public void testCurrentDate() throws Exception {

        Date curDate = (Date)FunctionMethods.currentDate();
    
        Calendar cal1 = Calendar.getInstance();
        cal1.setTime(curDate);
       
        assertEquals(cal1.get(Calendar.HOUR_OF_DAY), 0);
View Full Code Here

        helpInvokeMethod("sqrt", new Object[] { new Double("4")}, new Double("2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }
   
    @Test public void testInvokeDayName() {
        for (int i = 0; i < FunctionMethods.dayNames.length; i++) {
            Date time = TimestampUtil.createDate(100, 0, i + 2);
            helpInvokeMethod("dayName", new Object[] { time }, FunctionMethods.dayNames[i]); //$NON-NLS-1$
        }
    }
View Full Code Here

        helpInvokeMethod("month", new Object[] { time }, new Integer(1)); //$NON-NLS-1$
    }
   
    @Test public void testInvokeMonthName() {
        for (int i = 0; i < FunctionMethods.monthNames.length; i++) {
            Date time = TimestampUtil.createDate(100, i, 1);
            helpInvokeMethod("monthName", new Object[] { time }, FunctionMethods.monthNames[i]); //$NON-NLS-1$
        }
    }
View Full Code Here

   * @throws TransformationException if value is an incorrect input type or
   * the transformation fails
   */
  public Object transformDirect(Object value) throws TransformationException {
    value = ((String) value).trim();
    Date result = null;
    try {
      result = Date.valueOf( (String) value );
    } catch(Exception e) {
      throw new TransformationException(e, "ERR.003.029.0018", CorePlugin.Util.getString("ERR.003.029.0018", value)); //$NON-NLS-1$ //$NON-NLS-2$
    }
    if (!result.toString().equals(value)) {
      throw new TransformationException(CorePlugin.Util.getString("transform.invalid_string_for_date", value, getTargetType().getSimpleName())); //$NON-NLS-1$
    }
    return result;
  }
View Full Code Here

   * @return The value of the column as a Date object.
   * @throws SQLException
   *     if a results access error occurs or transform fails.
   */
  public Date getDate(int columnIndex, Calendar cal) throws SQLException {
    Date value = DataTypeTransformer.getDate(getObject(columnIndex));

    if (value != null && cal != null) {
      value = TimestampWithTimezone.createDate(value,
          getDefaultCalendar().getTimeZone(), cal);
    }
View Full Code Here

        recurrenceVO = activity.getRecurrence();
        activityForm.setActivityRecurringFrequency(recurrenceVO.getTimePeriod());

        // if date is not null convert from timestamp to String
        if (recurrenceVO.getStartDate() != null) {
          Date recurStartDate = recurrenceVO.getStartDate();
          Calendar recurStart = new GregorianCalendar();
          recurStart.setTime(recurStartDate);
          activityForm.setActivityRecurStartDate(df.format(recurStart.getTime()));
          activityForm.setActivityRecurringStartTime(tf.format(recurStart.getTime()));
        }

        if (recurrenceVO.getUntil() != null) {
          Date recurEndDate = recurrenceVO.getUntil();
          Calendar recurEnd = new GregorianCalendar();
          recurEnd.setTime(recurEndDate);
          activityForm.setActivityRecurEndDate(df.format(recurEnd.getTime()));
        }
View Full Code Here

      try {
        recurStart.setTime(df.parse(activityForm.getActivityRecurStartDate()));
      } catch (ParseException e) {
        logger.error("[fillBasic]: Exception", e);
      }
      recur.setStartDate(new Date(recurStart.getTimeInMillis()));

      if (CVUtility.notEmpty(activityForm.getActivityRecurEndDate())) {
        Calendar recurEnd = new GregorianCalendar();
        try {
          recurEnd.setTime(df.parse(activityForm.getActivityRecurEndDate()));
        } catch (ParseException e) {
          logger.error("[fillBasic]: Exception", e);
        }
        recur.setUntil(new Date(recurEnd.getTimeInMillis()));
      }
      recur.setTimePeriod(activityForm.getActivityRecurringFrequency());
      HashMap mapRecurrence = new HashMap();
      mapRecurrence.put("FREQUENCY", activityForm.getActivityRecurringFrequency());
      boolean isRecurr = false;
View Full Code Here

TOP

Related Classes of java.sql.Date

Copyright © 2018 www.massapicom. 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.