List of usage examples for java.sql Time Time
public Time(long time)
Time
object using a milliseconds time value. From source file:com.jaspersoft.jasperserver.war.cascade.handlers.converters.TimeDataConverter.java
@Override public Time stringToValue(String rawData) throws ParseException { return StringUtils.isNotEmpty(rawData) ? new Time(getFormatter().parse(rawData).getTime()) : null; }
From source file:com.microsoft.sqlserver.testframework.sqlType.SqlTime.java
public Object createdata() { Time temp = new Time( ThreadLocalRandom.current().nextLong(((Time) minvalue).getTime(), ((Time) maxvalue).getTime())); String timeNano = temp.toString() + "." + RandomStringUtils.randomNumeric(this.precision); // can pass String rather than converting to loacTime, but leaving it // unchanged for now to handle prepared statements return LocalTime.parse(timeNano, formatter); }
From source file:cherry.foundation.type.converter.LocalTimeConverterTest.java
@Test public void testConvert() { LocalTime now = LocalTime.now(); for (int i = -86400; i <= 86400; i++) { LocalTime lt = now.plusSeconds(i); Time time = new Time(lt.getMillisOfDay()); assertThat(cs.convert(time, LocalTime.class), is(lt)); assertThat(cs.convert(lt, Time.class), is(time)); }/*from w w w.jav a 2s. co m*/ }
From source file:cherry.foundation.type.jdbc.CustomBeanPropertySqlParameterSource.java
@Override public Object getValue(String paramName) throws IllegalArgumentException { Object object = super.getValue(paramName); if (object instanceof LocalDateTime) { LocalDateTime ldt = (LocalDateTime) object; return new Timestamp(ldt.toDate().getTime()); }// www .j a v a 2s . c om if (object instanceof LocalDate) { LocalDate ld = (LocalDate) object; return new Date(ld.toDate().getTime()); } if (object instanceof LocalTime) { LocalTime lt = (LocalTime) object; return new Time((long) lt.getMillisOfDay()); } if (object instanceof SecureType<?>) { SecureType<?> st = (SecureType<?>) object; return st.crypto(); } if (object instanceof Code<?>) { Code<?> ce = (Code<?>) object; return ce.code(); } return object; }
From source file:com.huateng.ebank.framework.util.DateUtil.java
/** * ?? * * @return */ public static Time getCurrentTime() { return new Time(System.currentTimeMillis()); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.freemarker.DumpTestController.java
@Override protected ResponseValues processRequest(VitroRequest vreq) { Map<String, Object> body = new HashMap<String, Object>(); body.put("title", "Freemarker Test"); body.put("dog", "Rover"); body.put("int", 7); body.put("bool", false); body.put("now", new Date()); java.sql.Date date = new java.sql.Date(1302297332043L); body.put("date", date); Time time = new Time(1302297332043L); body.put("time", time); Timestamp ts = new Timestamp(1302297332043L); body.put("timestamp", ts); // List of strings List<String> fruit = new ArrayList<String>(); fruit.add("apples"); fruit.add("bananas"); fruit.add("peaches"); body.put("fruit", fruit); // Mixed list List<Object> mixedList = new ArrayList<Object>(); String myString = "apples"; mixedList.add(myString);/* w ww. j a v a 2s . co m*/ int myInt = 4; mixedList.add(myInt); boolean myBool = true; mixedList.add(myBool); List<String> myList = new ArrayList<String>(); myList.add("dog"); myList.add("cat"); myList.add("elephant"); mixedList.add(myList); body.put("mixedList", mixedList); // Collection (non-indexable) Set<Integer> odds = new HashSet<Integer>(); for (int i = 0; i <= 10; i++) { if (i % 2 == 1) { odds.add(i); } } body.put("oddNums", new SimpleCollection(odds)); // String-string map Map<String, String> myMap = new HashMap<String, String>(); myMap.put("Albany", "New York"); myMap.put("St. Paul", "Minnesota"); myMap.put("Austin", "Texas"); myMap.put("Sacramento", "California"); myMap.put("Richmond", "Virginia"); body.put("capitals", myMap); // Mixed map Map<String, Object> mixedMap = new HashMap<String, Object>(); mixedMap.put("myString", myString); mixedMap.put("myBoolean", myBool); mixedMap.put("myNumber", myInt); Date myDate = new Date(); mixedMap.put("myDate", myDate); mixedMap.put("myList", myList); mixedMap.put("capitals", myMap); body.put("mixedMap", mixedMap); // Java object Employee jdoe = getEmployee(); body.put("employeeLimited", jdoe); try { body.put("employeeInvisible", wrap(jdoe, BeansWrapper.EXPOSE_NOTHING)); body.put("employeeFull", wrap(jdoe, BeansWrapper.EXPOSE_SAFE)); } catch (TemplateModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return new TemplateResponseValues(TEMPLATE_DEFAULT, body); }
From source file:TestCalificarEstablecimiento.java
@Test @Transactional/*from w ww . j a v a 2 s. c o m*/ @Rollback(true) public void testCalificarEstablecimientoPorMusico() throws OperationFailedException { Cliente c1 = new Cliente(123, "Zlatan Ibrahimovic"); logica.registrarCliente(c1); Ensayo es1 = new Ensayo(555, c1, "Ensayo en la sala VIP"); //es1.setCalificacions(new HashSet<Calificacion>()); logica.registrarEnsayo(es1); DetalleInstrumento det = new DetalleInstrumento(1, "Guitarra"); logica.registrarDetalleInstrumento(det); Establecimiento est = new Establecimiento(777, "La casa de judas", "123.456.789-1", "calle falsa #nunca existio", new Time(700), new Time(1900), 90.2, "Usaquen", "00000000", "21000813610123456789"); logica.registrarEstablecimiento(est); Instrumento ins = new Instrumento(333, det, es1, est, "1000"); logica.registrarInstrumento(ins); logica.calificarEstablecimiento(c1.getIdCliente(), es1.getIdEnsayo(), 4, "Fue muy bueno por que regalaron te"); Ensayo ens = logica.consultarEnsayo(555); Calificacion cals = logica.consultarCalificacionDeEnsayo(ens.getIdEnsayo()); assertEquals(cals.getCalificacionEstablecimiento(), 4); }
From source file:com.wavemaker.commons.json.deserializer.WMDateDeSerializer.java
public static Date getDate(String value) { if (StringUtils.isBlank(value)) { return null; }// w w w.j a va 2 s . c om try { Date parsedDate = new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT).parse(value); return new Timestamp(parsedDate.getTime()); } catch (ParseException e) { logger.trace("{} is not in the expected date time format {}", value, DEFAULT_DATE_TIME_FORMAT); } try { Date parsedDate = new SimpleDateFormat(DEFAULT_DATE_FORMAT).parse(value); return new java.sql.Date(parsedDate.getTime()); } catch (ParseException e) { logger.trace("{} is not in the expected date format {}", value, DEFAULT_DATE_FORMAT); } try { Date parsedDate = new SimpleDateFormat(DEFAULT_TIME_FORMAT).parse(value); return new Time(parsedDate.getTime()); } catch (ParseException e) { logger.trace("{} is not in the expected time format {}", value, DEFAULT_TIME_FORMAT); } throw new WMRuntimeException("Failed to parse the string " + value + "as java.util.Date"); }
From source file:com.tesora.dve.db.mysql.MysqlNativeResultHandler.java
@Override protected byte[] getDateAsBytes(ColumnMetadata uc, Object obj) { if (uc.getDataType() == Types.TIME) return getTimeAsBytes(uc, new Time(((Date) obj).getTime())); if (uc.getDataType() == Types.TIMESTAMP) return getTimestampAsBytes(uc, new Timestamp(((Date) obj).getTime())); if (((Date) obj).equals(ZERO_DATE_INDICATOR)) return ZERO_DATE.getBytes(); return dateFormatter.format((Date) obj).getBytes(); }
From source file:com.impetus.kundera.property.accessor.SQLTimeAccessor.java
@Override public Time fromBytes(Class targetClass, byte[] b) { // String s;/* w w w .j a va 2 s . c om*/ // try // { // // if (b == null) // { // return null; // } // s = new String(b, Constants.ENCODING); // } // catch (UnsupportedEncodingException e) // { // throw new PropertyAccessException(e); // } // return fromString(targetClass, s); try { if (b == null) { return null; } // In case date.getTime() is stored in DB. LongAccessor longAccessor = new LongAccessor(); return new Time(longAccessor.fromBytes(targetClass, b)); } catch (Exception e) { log.error("Error occured, Caused by {}.", e); throw new PropertyAccessException(e); } }