Package java.sql

Examples of java.sql.Timestamp


  private String decorateFormat(int index, List rowData, FieldDecoration decoration, String out)
  {
    Integer listTypeInteger = new Integer(this.listObject.getParameters().getValueListType());
    StringBuffer decoratedField = new StringBuffer();
    Date valueDate = null;
    Timestamp timeStamp = null;
    boolean flagUrl = true;
    String valueString = "";
    int decorationType = decoration.getFieldDecorationType();

    Object content = rowData.get(decoration.getParameter() - 1);

    switch (decorationType) {
      case FieldDecoration.urlType:
        String folderType = "";
        if (listTypeInteger.intValue() == ValueListConstants.FILE_LIST_TYPE && this.listObject.getLookupType() != null
            && this.listObject.getLookupType().equals("lookup")) {
          folderType = rowData.get(ValueListConstants.KB_FILE_EMAIL_HACK_INDEX - 1).toString();
          if (folderType != null && folderType.equals("FILE")) {
            flagUrl = false;
          }
        }

        if (flagUrl) {
          // display the string in Hyper link format
          decoratedField.append(ValueListConstants.ANCHOR_PART_OPEN);
          decoratedField.append("class=\"plainLink\" ");
          decoratedField.append("href=\"javascript:");
          decoratedField.append(decoration.getUrlOpen());
          valueString = content.toString();
          valueString = valueString.replaceAll("\"", """);

          // For file and knowledgebase lists we will append type parameter to
          // the url.
          if (listTypeInteger.intValue() == ValueListConstants.KNOWLEDGEBASE_LIST_TYPE
              || listTypeInteger.intValue() == ValueListConstants.FILE_LIST_TYPE) {
            valueString = valueString.concat("&type=" + rowData.get(ValueListConstants.KB_FILE_EMAIL_HACK_INDEX - 1));
            if (this.listObject.isLookup()) {
              valueString += ValueListConstants.AMP + "actionType=" + this.listObject.getLookupType();
            }
          }
          decoratedField.append(valueString);

          if (this.pageContext.findAttribute("listScope") != null) {
            decoratedField.append("&listScope=");
            decoratedField.append(this.request.getAttribute("listScope"));
          }

          if (this.listObject.getCurrentLinkParameters() != null && !this.listObject.getCurrentLinkParameters().equals("")) {
            decoratedField.append(this.listObject.getCurrentLinkParameters());
          }
          decoratedField.append(decoration.getUrlClose());
          decoratedField.append("\"");
          decoratedField.append(ValueListConstants.CLOSE);
          // For completed activities
          if (((listTypeInteger.intValue() == ValueListConstants.ACTIVITY_LIST_TYPE)
              || (listTypeInteger.intValue() == ValueListConstants.APPOINTMENT_LIST_TYPE)
              || (listTypeInteger.intValue() == ValueListConstants.CALL_LIST_TYPE)
              || (listTypeInteger.intValue() == ValueListConstants.FORECASTSALES_LIST_TYPE)
              || (listTypeInteger.intValue() == ValueListConstants.MEETING_LIST_TYPE)
              || (listTypeInteger.intValue() == ValueListConstants.NEXTACTION_LIST_TYPE)
              || (listTypeInteger.intValue() == ValueListConstants.TODO_LIST_TYPE) || (listTypeInteger.intValue() == ValueListConstants.TASK_LIST_TYPE))
              && (index == ValueListConstants.ACTIVITY_TITLE_INDEX)) {
            Object columnData = rowData.get(ValueListConstants.ACTIVITY_STATUS_INDEX - 1);
            if (((String) columnData).indexOf("Completed") != -1) {
              decoratedField.append(ValueListConstants.SPAN_PART_OPEN);
              decoratedField.append("class=\"completedActivity\" ");
              decoratedField.append(ValueListConstants.CLOSE);
              decoratedField.append(out);
              decoratedField.append(ValueListConstants.SPAN_CLOSE);
            } else {
              decoratedField.append(out);
              decoratedField.append(ValueListConstants.ANCHOR_CLOSE);
            }
          } else {
            decoratedField.append(out);
            decoratedField.append(ValueListConstants.ANCHOR_CLOSE);
          }
        } else {
          decoratedField.append(out);
        }
        break;
      case FieldDecoration.dateType: {
        // use the standard i18n way of formating these.
        // that means using the default formats based on locale.
        if (content != null) {
          DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, this.locale);
          if (content instanceof Timestamp) {
            timeStamp = (Timestamp) content;
            valueDate = new Date(timeStamp.getTime());
            valueString = df.format(valueDate);
          }
          if (content instanceof java.sql.Date) {
            java.sql.Date dateStamp = (java.sql.Date) content;
            valueString = df.format(dateStamp);
          }
          if (content instanceof Long) {
            Long dateObject = (Long) content;
            valueDate = new Date();
            valueDate.setTime(dateObject.longValue());
            valueString = df.format(valueDate);
          }
          decoratedField.append(valueString);
        }
        break;
      }
      case FieldDecoration.dateTimeType: {
        DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, this.locale);
        timeStamp = (Timestamp) content;
        if (timeStamp != null) {
          valueDate = new Date(timeStamp.getTime());
          valueString = df.format(valueDate);
        }
        decoratedField.append(valueString);
        break;
      }
      case FieldDecoration.timeType: {
        DateFormat df = DateFormat.getTimeInstance(DateFormat.MEDIUM, this.locale);
        if (content instanceof Timestamp) {
          timeStamp = (Timestamp) content;
          valueDate = new Date(timeStamp.getTime());
          if (timeStamp != null) {
            valueDate = new Date(timeStamp.getTime());
            valueString = df.format(valueDate);
          }
        }
        if (content instanceof Long) {
          Long dateObject = (Long) content;
          if (dateObject != null) {
            valueDate = new Date();
            valueDate.setTime(dateObject.longValue());
            valueString = df.format(dateObject);
          }
        }
        decoratedField.append(valueString);
        break;
      }
      case FieldDecoration.fileSizeType:
        // display the string to file Size
        // which in byte to GB,MB,KB
        float size = (new Float(content.toString())).floatValue();
        DecimalFormat df = new DecimalFormat("###.#");
        Integer s = new Integer((int) size);
        valueString = s.toString();
        if (size > 1000000000) {
          size /= 1073741824; // 1GB
          valueString = df.format(size) + "GB";
        } else if (size > 1000000) {
          size /= 1048576; // 1MB
          valueString = df.format(size) + "MB";
        } else if (size > 1000) {
          size /= 1024; // 1KB
          valueString = df.format(size) + "KB";
        }
        decoratedField.append(valueString);
        break;

      case FieldDecoration.moneyType:
        // display the string to currency format
        NumberFormat numFormatter = NumberFormat.getCurrencyInstance(this.locale);
        if (content == null) {
          content = "0";
        }
        valueString = content.toString();
        Double doubleValue = new Double(valueString);
        if (doubleValue != null) {
          String contentFormated = numFormatter.format(doubleValue.doubleValue());
          decoratedField.append(contentFormated);
        }
        break;
      case FieldDecoration.hourType:
        // We are using the old version of mysql we must have to do this..
        // In futher version of mysql 4.1.1 as the datediff function we can use
        // that, but now no choice
        // we have to do this calculation.

        int startTimeIndex = ((Integer) ValueListConstants.timeslipDurationCalc.get("Start")).intValue();
        int endTimeIndex = ((Integer) ValueListConstants.timeslipDurationCalc.get("End")).intValue();

        Object startTimeObject = rowData.get(startTimeIndex - 1);
        Object endTimeObject = rowData.get(endTimeIndex - 1);
        long startTime = 0;
        long endTime = 0;
        if (startTimeObject != null && startTimeObject instanceof Timestamp) {
          Timestamp startTimeStamp = (Timestamp) startTimeObject;
          if (startTimeStamp != null) {
            startTime = startTimeStamp.getTime();
          }
        }
        if (endTimeObject != null && endTimeObject instanceof Timestamp) {
          Timestamp endTimeStamp = (Timestamp) endTimeObject;
          if (endTimeStamp != null) {
            endTime = endTimeStamp.getTime();
          }
        }

        if (startTime != 0 && endTime != 0) {
          long diffTime = endTime - startTime;
View Full Code Here


    setIsMileStone(dynaForm.getMilestone());

    setIndividualID(Integer.parseInt(dynaForm.getManagerID()));

    if (!dynaForm.getStartyear().equals("")) {
      Timestamp startTS = DateUtility.createTimestamp(dynaForm.getStartyear(), dynaForm
          .getStartmonth(), dynaForm.getStartday());
      setStart(CVUtility.convertTimeZone(startTS, TimeZone.getTimeZone(tz), TimeZone
          .getTimeZone("EST")));
    }
    if (!dynaForm.getEndyear().equals("")) {
      Timestamp endTS = DateUtility.createTimestamp(dynaForm.getEndyear(), dynaForm.getEndmonth(),
          dynaForm.getEndday());
      setEnd(CVUtility
          .convertTimeZone(endTS, TimeZone.getTimeZone(tz), TimeZone.getTimeZone("EST")));
    }
View Full Code Here

      cvdal.setInt(1, searchVO.getModuleID());
      cvdal.setInt(2, individualID);
      cvdal.setInt(3, individualID);
      cvdal.setRealDate(4, new java.sql.Date(new Date().getTime()));
      cvdal.setInt(5, individualID);
      cvdal.setRealTimestamp(6, new Timestamp(new Date().getTime()));
      cvdal.setString(7, searchVO.getName());

      cvdal.executeUpdate();
      newSearchID = cvdal.getAutoGeneratedKey();
View Full Code Here

      sqlString.append("SearchID = ?");
      cvdal.setSqlQuery(sqlString.toString());
      cvdal.setInt(1, searchVO.getModuleID());
      cvdal.setInt(2, searchVO.getOwnerID());
      cvdal.setInt(3, individualID);
      cvdal.setRealTimestamp(4, new Timestamp(new Date().getTime()));
      cvdal.setString(5, searchVO.getName());
      cvdal.setInt(6, searchVO.getSearchID());

      recordsAffected = cvdal.executeUpdate();
View Full Code Here

      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, site.getId());
      q.setInteger(1, TopicOutlineBean.STATUS_NORMAL);
      Calendar cur_time = Calendar.getInstance();
      cur_time.add(Calendar.DATE, -days);
      q.setTimestamp(2, new Timestamp(cur_time.getTime().getTime()));
      if(forum != null)
        q.setInteger(3, forum.getId());
      if(fromIdx > 0)
        q.setFirstResult(fromIdx);
      q.setMaxResults(count);
View Full Code Here

        }
    }
   
    private static class TimestampColumnSerializer extends ColumnSerializer {
        protected void writeObject(ObjectOutput out, Object obj) throws IOException {
            Timestamp ts =  (Timestamp)obj;
            out.writeLong(ts.getTime());
            out.writeInt(ts.getNanos());
        }
View Full Code Here

     */
    public static Timestamp createTimestamp(int year, int month, int date, int hour, int minute, int second, int nano) {
        primeCalendar();
        CAL.get().set(year + 1900, month, date, hour, minute, second);
        long millis = CAL.get().getTime().getTime();
        Timestamp ts = new Timestamp(millis);
        ts.setNanos(nano);
        return ts;
    }
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();
    Timestamp result = null;
    try {
      result = Timestamp.valueOf( (String) value );
    } catch(Exception e) {
      throw new TransformationException(e, "ERR.003.029.0024", CorePlugin.Util.getString("ERR.003.029.0024", value)); //$NON-NLS-1$ //$NON-NLS-2$
    }
    //validate everything except for fractional seconds
    if (!((String)value).startsWith(result.toString().substring(0, 19))) {
      throw new TransformationException(CorePlugin.Util.getString("transform.invalid_string_for_date", value, getTargetType().getSimpleName())); //$NON-NLS-1$
    }
    return result;
  }
View Full Code Here

        assertEquals(expected, getString(TestLiteralImpl.example(Boolean.TRUE)));
        long now = System.currentTimeMillis();
        Date date = new Date(now);
        expected = "{d '" + date.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
        assertEquals(expected, getString(TestLiteralImpl.example(date)));
        Timestamp ts = new Timestamp(now);
        expected = "{ts '" + ts.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
        assertEquals(expected, getString(TestLiteralImpl.example(ts)));
        Time t = new Time(now);
        expected = "{t '" + t.toString() + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
        assertEquals(expected, getString(TestLiteralImpl.example(t)));
    }
View Full Code Here

    }

    // Source = TIMESTAMP
   
    public void testTimestampToString() throws Exception {
        Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);       
        helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "char({ts '2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

TOP

Related Classes of java.sql.Timestamp

Copyright © 2015 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.