Package java.sql

Examples of java.sql.Date


            break;
        case CURDATE:
        case CURRENT_DATE: {
            long now = session.getTransactionStart();
            // need to normalize
            result = ValueDate.get(new Date(now));
            break;
        }
        case CURTIME:
        case CURRENT_TIME: {
            long now = session.getTransactionStart();
View Full Code Here


        case LOCAL_DATE: {
            return ValueDate.fromDateValue(readVarLong());
        }
        case Value.DATE: {
            long x = readVarLong() * MILLIS_PER_MINUTE;
            return ValueDate.get(new Date(DateTimeUtils.getTimeUTCWithoutDst(x)));
        }
        case LOCAL_TIME: {
            long nanos = readVarLong() * 1000000 + readVarLong();
            return ValueTime.fromNanos(nanos);
        }
View Full Code Here

    public Date getDate(int columnIndex, Calendar calendar) throws SQLException {
        try {
            if (isDebugEnabled()) {
                debugCode("getDate(" + columnIndex + ", calendar)");
            }
            Date x = get(columnIndex).getDate();
            return DateTimeUtils.convertDateToCalendar(x, calendar);
        } catch (Exception e) {
            throw logAndConvert(e);
        }
    }
View Full Code Here

    public Date getDate(String columnLabel, Calendar calendar) throws SQLException {
        try {
            if (isDebugEnabled()) {
                debugCode("getDate(" + StringUtils.quoteJavaString(columnLabel) + ", calendar)");
            }
            Date x = get(columnLabel).getDate();
            return DateTimeUtils.convertDateToCalendar(x, calendar);
        } catch (Exception e) {
            throw logAndConvert(e);
        }
    }
View Full Code Here

          }
        }

      case Types.DATE:
        {
          Date date = set.getDate(field);
          if (date != null) {
            Context context = Context.getInstance();
            Calendar cal = Calendar.getInstance(context.getTimeZone(), context.getLocale());
            cal.setTime(date);
            return new AnyCalendar(cal);
View Full Code Here

          }
        }

      case Types.DATE:
        {
          Date date = stmt.getDate(field);
          if (date != null) {
            Context context = Context.getInstance();
            Calendar cal = Calendar.getInstance(context.getTimeZone(), context.getLocale());
            cal.setTime(date);
            return new AnyCalendar(cal);
View Full Code Here

      throw new NullPointerException();
    }
    try
    {
      final java.util.Date date = dateFormat.parse(s);
      return new Date(date.getTime());
    }
    catch (ParseException e)
    {
      throw new BeanException("Not a parsable SQL-date");
    }
View Full Code Here

            // Date date = new Date(time);
            // String txt = "YYYY-MM-DD HH24:MI:SS"
            String txt = "2005-11-05 23:04:31.345";
            DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
            long time = format.parse(txt).getTime();
            Date date = new Date(time);
            System.out.println("Date: '" + time + "' is '" + date.toString() + "' and again as millis: '" + date.getTime());
            PreparedStatement st1 = conn.prepareStatement("INSERT INTO " + this.tableName + " VALUES (?)");
            st1.setDate(1, date);
            st1.executeUpdate();
            st1.close();
            st1 = null;

            st1 = conn.prepareStatement("SELECT * FROM " + tableName);
            ResultSet rs = st1.executeQuery();
            rs.next();
            Date date1 = rs.getDate(1);
            System.out.println("Date after taking it out from DB: '" + date1.getTime() + "'");
            System.out.println("Date diff: " + (date1.getTime() - date.getTime()));
            rs.close();
            st1.close();

            Thread.sleep(500L);
            Statement st2 = conn.createStatement();
View Full Code Here

  // ----------------------------------------------------------

  private String sqlldr (Object oValue) {
    String sClass;
    String sRetVal;
    Date dtValue;
    Timestamp tsValue;

    if (null==oValue) {
      sRetVal = "NULL";
    }
    else {
      sClass = oValue.getClass().getName();

      if (sClass.equals("java.lang.String"))
        sRetVal = "\"" + oValue.toString() + "\"";
      else if (sClass.equals("java.util.Date") || sClass.equals("java.sql.Date")) {
        dtValue = (Date) oValue;
        sRetVal = String.valueOf(dtValue.getYear()+1900) + "-";
        sRetVal += (dtValue.getMonth()+1<10 ? "0" + String.valueOf(dtValue.getMonth()+1) : String.valueOf(dtValue.getMonth()+1)) + "-";
        sRetVal += (dtValue.getDay()+1<10 ? "0" + String.valueOf(dtValue.getDay()+1) : String.valueOf(dtValue.getDay()+1)) + " ";
        sRetVal += (dtValue.getHours()<10 ? "0" + String.valueOf(dtValue.getHours()) : String.valueOf(dtValue.getHours())) + ":";
        sRetVal += (dtValue.getMinutes()<10 ? "0" + String.valueOf(dtValue.getMinutes()) : String.valueOf(dtValue.getMinutes())) + ":";
        sRetVal += (dtValue.getSeconds()<10 ? "0" + String.valueOf(dtValue.getSeconds()) : String.valueOf(dtValue.getSeconds()));
        dtValue = null;
      }
      else if (sClass.equals("java.sql.Timestamp")) {
        tsValue = (Timestamp) oValue;
        sRetVal = String.valueOf(tsValue.getYear()+1900) + "-";
View Full Code Here

        // HOUR_OF_DAY, MINUTE, SECOND, MILLISECOND
        cal.clear();
       
        SQLDate.setDateInCalendar(cal, encodedDate);

    return new Date(cal.getTimeInMillis());
  }
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.