Package java.sql

Examples of java.sql.Timestamp


       String timeFormat = (String) ((Constant)formatTimeFunction.getArgs()[1]).getValue();       
       String timestampValue = (String) timestampConstant.getValue();
      
       // Passed all the checks, so build the optimized version
       try {
         Timestamp ts = FunctionMethods.parseTimestamp(timestampValue, dateFormat + timeFormat);
           Constant dateConstant = new Constant(TimestampWithTimezone.createDate(ts));
           CompareCriteria dateCompare = new CompareCriteria(formatDateFunction.getArgs()[0], CompareCriteria.EQ, dateConstant);

           Constant timeConstant = new Constant(TimestampWithTimezone.createTime(ts));
           CompareCriteria timeCompare = new CompareCriteria(formatTimeFunction.getArgs()[0], CompareCriteria.EQ, timeConstant);
View Full Code Here


        function = result;
        break;
      }
      case 1: {//from_unixtime(a) => timestampadd(SQL_TSI_SECOND, a, new Timestamp(0))
        Function result = new Function(FunctionLibrary.TIMESTAMPADD,
            new Expression[] {new Constant(NonReserved.SQL_TSI_SECOND), function.getArg(0), new Constant(new Timestamp(0)) });
        //resolve the function
        FunctionDescriptor descriptor =
          funcLibrary.findFunction(FunctionLibrary.TIMESTAMPADD, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.TIMESTAMP });
        result.setFunctionDescriptor(descriptor);
        result.setType(DataTypeManager.DefaultDataClasses.TIMESTAMP);
View Full Code Here

      }
    } else if(e instanceof Literal) {
      try {
        if(((Literal)e).getType().equals(Class.forName(Timestamp.class.getName()))) {
          LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Found an expression that uses timestamp; converting to LDAP string format."); //$NON-NLS-1$
          Timestamp ts = (Timestamp)((Literal)e).getValue();
          Date dt = new Date(ts.getTime());
          //TODO: Fetch format if provided.
          SimpleDateFormat sdf = new SimpleDateFormat(LDAPConnectorConstants.ldapTimestampFormat);
          expressionName = sdf.format(dt);
          LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Timestamp to stsring is: " + expressionName); //$NON-NLS-1$
        }
View Full Code Here

            if(rExp instanceof Literal) {
              Literal literal = (Literal)rExp;
              if (column.getJavaType().equals(Boolean.class)) {
                queryString.append(((Boolean)literal.getValue()).toString());
              } else if (column.getJavaType().equals(java.sql.Timestamp.class)) {
                Timestamp datetime = (java.sql.Timestamp)literal.getValue();
                String value = Util.getSalesforceDateTimeFormat().format(datetime);
                String zoneValue = Util.getTimeZoneOffsetFormat().format(datetime);
                queryString.append(value).append(zoneValue.subSequence(0, 3)).append(':').append(zoneValue.subSequence(3, 5));
              } else if (column.getJavaType().equals(java.sql.Time.class)) {
                String value = Util.getSalesforceDateTimeFormat().format((java.sql.Time)literal.getValue());
View Full Code Here

  @AfterClass public static void tearDown() {
    TimestampWithTimezone.resetCalendar(null);
  }
   
    @Test public void test24HourDateTimeTranslation() throws Exception {
        Timestamp ts = TimestampUtil.createTimestamp(100, 0, 2, 14, 14, 5, 6000);
       
        String value = XMLValueTranslator.translateToXMLValue(ts, DataTypeManager.DefaultDataClasses.TIMESTAMP, XMLValueTranslator.DATETIME);
        assertEquals("2000-01-02T20:14:05.000006Z", value); //$NON-NLS-1$
    }
View Full Code Here

        String value = XMLValueTranslator.translateToXMLValue(ts, DataTypeManager.DefaultDataClasses.TIMESTAMP, XMLValueTranslator.DATETIME);
        assertEquals("2000-01-02T20:14:05.000006Z", value); //$NON-NLS-1$
    }
   
    @Test public void testDateTimeTranslation() throws Exception {
        Timestamp ts = TimestampUtil.createTimestamp(100, 0, 2, 3, 4, 5, 6);
       
        String value = XMLValueTranslator.translateToXMLValue(ts, DataTypeManager.DefaultDataClasses.TIMESTAMP, XMLValueTranslator.DATETIME);
        assertEquals("2000-01-02T09:04:05Z", value); //$NON-NLS-1$
       
        ts.setNanos(6000);
       
        value = XMLValueTranslator.translateToXMLValue(ts, DataTypeManager.DefaultDataClasses.TIMESTAMP, XMLValueTranslator.DATETIME);
        assertEquals("2000-01-02T09:04:05.000006Z", value); //$NON-NLS-1$
       
        ts.setNanos(0);

        value = XMLValueTranslator.translateToXMLValue(ts, DataTypeManager.DefaultDataClasses.TIMESTAMP, XMLValueTranslator.DATETIME);
        assertEquals("2000-01-02T09:04:05Z", value); //$NON-NLS-1$
       
        ts = TimestampUtil.createTimestamp(-2000, 0, 2, 3, 4, 5, 6);
View Full Code Here

        value = XMLValueTranslator.translateToXMLValue(new BigInteger("-10000"), DataTypeManager.DefaultDataClasses.BIG_INTEGER, XMLValueTranslator.GYEAR); //$NON-NLS-1$
        assertEquals("-10000", value); //$NON-NLS-1$
    }
   
    @Test public void testgYearMonthTranslation() throws Exception {
        Timestamp ts = TimestampUtil.createTimestamp(100, 0, 4, 6, 8, 10, 12);
       
        String value = XMLValueTranslator.translateToXMLValue(ts, DataTypeManager.DefaultDataClasses.TIMESTAMP, XMLValueTranslator.GYEARMONTH);
        assertEquals("2000-01Z", value); //$NON-NLS-1$
       
        ts = TimestampUtil.createTimestamp(-30000, 0, 4, 6, 8, 10, 12);
View Full Code Here

        log("Done");    //$NON-NLS-1$
    }
   
    private void log(String msg) {
      if (DEBUG) {
        System.out.println((new Timestamp(System.currentTimeMillis())).toString() + " " //$NON-NLS-1$
            Thread.currentThread().getName() + ": " + msg);     //$NON-NLS-1$
      }
    }
View Full Code Here

      }
      dateFormat = new SimpleDateFormat(timestampFormat);
      try {
        if(strResult != null) {
          Date dateResult = dateFormat.parse(strResult);
          Timestamp tsResult = new Timestamp(dateResult.getTime());
          row.add(tsResult);
        } else {
          row.add(null);
        }
      } catch(ParseException pe) {
View Full Code Here

          int estimatedclosemonth1 = Integer.parseInt(estimatedclosemonth);
          int estimatedcloseday1 = Integer.parseInt(estimatedcloseday);
          int estimatedcloseyear1 = Integer.parseInt(estimatedcloseyear);
          Calendar estimatedClose = new GregorianCalendar();
          estimatedClose.set(estimatedcloseyear1, estimatedclosemonth1 - 1, estimatedcloseday1);
          opportunityVO.setEstimatedClose(new Timestamp(estimatedClose.getTimeInMillis()));
        } catch (NumberFormatException nfe) {
          logger.info("[execute]: blank date fields");
        } catch (Exception e) {
          logger.error("[execute]: Exception");
        }
      }

      if (typeofoperation.equals(SaleConstantKeys.ADD)) {
        remote.addOpportunity(ownerId, opportunityVO);
      } else if (typeofoperation.equals(SaleConstantKeys.EDIT)) {
        String opportunityid = request.getParameter("opportunityid");

        if ((opportunityForm.getActualclosemonth() != null) && (opportunityForm.getActualcloseday() != null)
            && (opportunityForm.getActualcloseyear() != null)) {
          String actualclosemonth = opportunityForm.getActualclosemonth();
          String actualcloseday = opportunityForm.getActualcloseday();
          String actualcloseyear = opportunityForm.getActualcloseyear();

          try {
            int actualclosemonth1 = Integer.parseInt(actualclosemonth);
            int actualcloseday1 = Integer.parseInt(actualcloseday);
            int actualcloseyear1 = Integer.parseInt(actualcloseyear);
            Calendar actualClose = new GregorianCalendar(actualcloseyear1, actualclosemonth1 - 1, actualcloseday1);
            opportunityVO.setActualclose(new Timestamp(actualClose.getTimeInMillis()));
          } catch (NumberFormatException nfe) {
            logger.info("[execute]: blank date fields");
          } catch (Exception e) {
            logger.error("[execute]: Exception", e);
          }
View Full Code Here

TOP

Related Classes of java.sql.Timestamp

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.