Package java.sql

Examples of java.sql.Date


    assertEquals(timestamp, result);
  }

  @Test
  public void testSqlDateConversion() {
    Date date = new Date(1L);
    Date result = (Date) converter.convert(Date.class, date);
    assertEquals(date, result);
  }
View Full Code Here


  @Test
  public void testXmlGregorianCalendar() {
    XMLGregorianCalendar xmlCalendar = mock(XMLGregorianCalendar.class);
    GregorianCalendar expected = new GregorianCalendar();
    when(xmlCalendar.toGregorianCalendar()).thenReturn(expected);
    Date date = new Date(expected.getTimeInMillis());

    assertEquals(date, converter.convert(Date.class, xmlCalendar));
  }
View Full Code Here

      ReportLocal reportLocal = reportHome.findByPrimaryKey(new ReportPK(reportId, this.dataSource));
      reportResult.setReportId(reportLocal.getReportId());
      reportResult.setModuleId(reportLocal.getModuleId());
      reportResult.setName(reportLocal.getName());
      reportResult.setSearchCriteria(getSearchCriteriaString(userId, reportId));
      Date dateFrom = reportLocal.getDateFrom();
      Date dateTo = reportLocal.getDateTo();

      try {
        String query = getQueryForResultReport(userId, reportId, search, dataAccessLayer);

        dataAccessLayer.setSqlQuery(query);
        resultSet = dataAccessLayer.executeQueryNonParsed();
        ResultSetMetaData metaData = resultSet.getMetaData();
        int cols = metaData.getColumnCount();
        int i = 0;
        boolean exclude = false;
        boolean[] isDate = new boolean[cols + 1];
        for (i = 1; i <= cols; i++) {
          isDate[i] = false;
        }
        for (i = 1; i <= cols; i++) {
          if ((Types.DATE == metaData.getColumnType(i) || Types.TIMESTAMP == metaData.getColumnType(i))
              && !metaData.getColumnName(i).equalsIgnoreCase("Modified") && !metaData.getColumnName(i).equalsIgnoreCase("Created")) {
            isDate[i] = true;
          }
        } // end for ( i = 1; i <= cols; i++)

        while (resultSet.next()) {
          resultLine = new ArrayList();
          exclude = false;
          for (i = 1; i <= cols; i++) {
            if (isDate[i]) {
              Date dateField = resultSet.getDate(i);
              if (dateField != null) {
                if (dateFrom != null && dateFrom.after(dateField)) {
                  exclude = true;
                }
                if (dateTo != null && dateTo.before(dateField)) {
View Full Code Here

      int recurId = dl.getAutoGeneratedKey();
      ArrayList rexDt = rv.getRecurrenceExcept();
      if (rexDt != null) {
        Iterator it = rexDt.iterator();
        while (it.hasNext()) {
          Date rdt = (Date)it.next();
          dl.clearParameters();
          dl.setSql("activity.addrecurrenceexception");
          dl.setInt(1, recurId);
          dl.setDate(2, rdt);
          dl.executeUpdate();
View Full Code Here

     * @param x the date
     * @param calendar the calendar
     * @return the date using the correct time zone
     */
    public static Date convertDateToCalendar(Date x, Calendar calendar) {
        return x == null ? null : new Date(convertToLocal(x, calendar));
    }
View Full Code Here

    public static Date convertDateValueToDate(long dateValue) {
        long millis = getMillis(TimeZone.getDefault(),
                yearFromDateValue(dateValue),
                monthFromDateValue(dateValue),
                dayFromDateValue(dateValue), 0, 0, 0, 0);
        return new Date(millis);
    }
View Full Code Here

    public String placeOrder(Order order) {
        orderList.add(order);
        String id = Integer.toString(orderList.size());
        order.setOrderId(id);
        order.setOrderDate(new Date(System.currentTimeMillis()));
        return id;
    }
View Full Code Here

                byte value = rs.getByte(columnIndex);
                v = rs.wasNull() ? (Value) ValueNull.INSTANCE : ValueByte.get(value);
                break;
            }
            case Value.DATE: {
                Date value = rs.getDate(columnIndex);
                v = value == null ? (Value) ValueNull.INSTANCE : ValueDate.get(value);
                break;
            }
            case Value.TIME: {
                Time value = rs.getTime(columnIndex);
View Full Code Here

                int minute = (int) (second / 60);
                second -= minute * 60;
                int hour = minute / 60;
                minute -= hour * 60;
                long millis = DateTimeUtils.getMillis(tz, year, month, day, hour, minute, (int) second, (int) ms);
                ms = DateTimeUtils.convertToLocal(new Date(millis), Calendar.getInstance(TimeZone.getTimeZone("UTC")));
                dateValue = DateTimeUtils.dateValueFromDate(ms);
                nanos += (ms - DateTimeUtils.absoluteDayFromDateValue(dateValue) * DateTimeUtils.MILLIS_PER_DAY) * 1000000;
            }
        }
        return ValueTimestamp.fromDateValueAndNanos(dateValue, nanos);
View Full Code Here

            return ValueByte.get(readByte());
        case Value.DATE:
            if (version >= Constants.TCP_PROTOCOL_VERSION_9) {
                return ValueDate.fromDateValue(readLong());
            } else if (version >= Constants.TCP_PROTOCOL_VERSION_7) {
                return ValueDate.get(new Date(DateTimeUtils.getTimeUTCWithoutDst(readLong())));
            }
            return ValueDate.get(new Date(readLong()));
        case Value.TIME:
            if (version >= Constants.TCP_PROTOCOL_VERSION_9) {
                return ValueTime.fromNanos(readLong());
            } else if (version >= Constants.TCP_PROTOCOL_VERSION_7) {
                return ValueTime.get(new Time(DateTimeUtils.getTimeUTCWithoutDst(readLong())));
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.