List of usage examples for java.sql Date getTime
public long getTime()
From source file:de.interseroh.report.formatters.DateFormatter.java
@Override public String print(Date date, Locale locale) { return getDateFormat(locale).format(new java.util.Date(date.getTime())); }
From source file:com.fusesource.examples.horo.db.typehandler.DateTimeTypeHandler.java
@Override public DateTime getNullableResult(ResultSet rs, String columnName) throws SQLException { Date date = rs.getDate(columnName); return (date == null) ? null : new DateTime(date.getTime()); }
From source file:com.fusesource.examples.horo.db.typehandler.DateTimeTypeHandler.java
@Override public DateTime getNullableResult(CallableStatement callableStatement, int i) throws SQLException { Date date = callableStatement.getDate(i); return (date == null) ? null : new DateTime(date.getTime()); }
From source file:com.impetus.kundera.property.accessor.SQLDateAccessor.java
@Override public Date getCopy(Object object) { Date d = (Date) object; return d != null ? new Date(d.getTime()) : null; }
From source file:gov.nih.nci.integration.dao.DefaultIHubMessageDao.java
/** * saveMessage//from w w w .j a va 2 s.co m * * @param referenceMessageId - MessageId * @param request - Message in the form of XMLString * @return Id - returned Id */ public Long saveMessage(Long referenceMessageId, String request) { final IHubMessage iHubMessage = new IHubMessage(); final java.util.Date currDt = new java.util.Date();// NOPMD iHubMessage.setStartTime(new Date(currDt.getTime())); iHubMessage.setRequest(request); iHubMessage.setReferenceMessageId(referenceMessageId); iHubMessage.setStatus(Status.PROCESS); return save(iHubMessage); }
From source file:ips1ap101.lib.base.util.StrUtils.java
public static Object getObjeto(String string, Class<?> clazz) { if (string == null || clazz == null) { return null; }/* ww w . ja va 2s . co m*/ try { String value = StringUtils.trimToNull(string); if (value == null) { return null; } else if (Character.class.isAssignableFrom(clazz)) { return new Character(value.charAt(0)); } else if (String.class.isAssignableFrom(clazz)) { // ALFANUMERICO return string; } else if (Boolean.class.isAssignableFrom(clazz)) { return BitUtils.valueOf(value); } else if (Byte.class.isAssignableFrom(clazz)) { return new Byte(new BigDecimal(value).byteValue()); } else if (Short.class.isAssignableFrom(clazz)) { return new Short(new BigDecimal(value).shortValue()); } else if (Integer.class.isAssignableFrom(clazz)) { // ENTERO return new Integer(new BigDecimal(value).intValue()); } else if (Long.class.isAssignableFrom(clazz)) { return new Long(new BigDecimal(value).longValue()); } else if (Float.class.isAssignableFrom(clazz)) { return new Float(new BigDecimal(value).floatValue()); } else if (Double.class.isAssignableFrom(clazz)) { return new Double(new BigDecimal(value).doubleValue()); } else if (BigInteger.class.isAssignableFrom(clazz)) { // ENTERO_GRANDE return new Long(new BigDecimal(value).longValue()); } else if (BigDecimal.class.isAssignableFrom(clazz)) { // NUMERICO return new BigDecimal(value); } else if (java.util.Date.class.isAssignableFrom(clazz)) { // FECHA_HORA java.util.Date dateTime = TimeUtils.parse(value); if (Timestamp.class.isAssignableFrom(clazz)) { return new Timestamp(dateTime.getTime()); } else if (Time.class.isAssignableFrom(clazz)) { return new Time(dateTime.getTime()); } else if (Date.class.isAssignableFrom(clazz)) { return new Date(dateTime.getTime()); } else { return dateTime; } } // } catch (NumberFormatException e) { // return null; } catch (RuntimeException e) { return null; } return null; }
From source file:org.apache.ddlutils.platform.DefaultValueHelper.java
/** * Converts the given default value from the specified original to the target * jdbc type./* w w w . j a v a 2s . c o m*/ * * @param defaultValue The default value * @param originalTypeCode The original type code * @param targetTypeCode The target type code * @return The converted default value */ public String convert(String defaultValue, int originalTypeCode, int targetTypeCode) { String result = defaultValue; if (defaultValue != null) { switch (originalTypeCode) { case Types.BIT: case Types.BOOLEAN: result = convertBoolean(defaultValue, targetTypeCode).toString(); break; case Types.DATE: if (targetTypeCode == Types.TIMESTAMP) { try { Date date = Date.valueOf(result); return new Timestamp(date.getTime()).toString(); } catch (IllegalArgumentException ex) { } } break; case Types.TIME: if (targetTypeCode == Types.TIMESTAMP) { try { Time time = Time.valueOf(result); return new Timestamp(time.getTime()).toString(); } catch (IllegalArgumentException ex) { } } break; } } return result; }
From source file:com.jason.sms.util.CustomSqlDateEditor.java
/** * Parse the Date from the given text, using the specified DateFormat. *///from w w w . j a v a2 s. co m @Override public void setAsText(String text) throws IllegalArgumentException { if (this.allowEmpty && !StringUtils.hasText(text)) { // Treat empty String as null value. setValue(null); } else if (text != null && this.exactDateLength >= 0 && text.length() != this.exactDateLength) { throw new IllegalArgumentException( "Could not parse date: it is not exactly" + this.exactDateLength + "characters long"); } else { try { java.util.Date date = this.dateFormat.parse(text); java.sql.Date sqlDate = new java.sql.Date(date.getTime()); setValue(sqlDate); } catch (ParseException ex) { throw new IllegalArgumentException("Could not parse date: " + ex.getMessage(), ex); } } }
From source file:org.jasig.portlet.ClassifiedsPortlet.service.AdServiceImpl.java
public List<Ad> getLatestAds(int nMaxResults) { final java.util.Date today = new java.util.Date(); final java.sql.Date sqlToday = new java.sql.Date(today.getTime()); final String query = "from Ad where STARTDATE <= ? and ENDDATE >= ? order by startDate desc "; final int maxResults = nMaxResults; HibernateCallback callback = new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { return session.createQuery(query).setCacheable(true).setDate(0, sqlToday).setDate(1, sqlToday) .setMaxResults(maxResults).list(); }/*from ww w . j ava 2 s .c o m*/ }; return (List<Ad>) getHibernateTemplate().execute(callback); }
From source file:com.impetus.kundera.property.accessor.SQLDateAccessor.java
@Override public String toString(Object object) { Date date = (Date) object; if (date == null) { return null; }/* www . ja v a 2 s . c o m*/ return String.valueOf(date.getTime())/*date.toString()*/; }