List of usage examples for java.sql Date Date
public Date(long date)
From source file:com.dianping.lion.dao.ibatis.ProductIbatisDaoTest.java
@Test public void testInsert() { int oriSize = productDao.findAll().size(); Product product = new Product(); product.setName("teamx"); product.setProductLeaderId(2);// w w w .j a v a 2s . c om product.setTeamId(1); product.setCreateTime(new Date(System.currentTimeMillis())); product.setModifyTime(new Date(System.currentTimeMillis())); id = productDao.create(product); int nowSize = productDao.findAll().size(); assertTrue(nowSize > oriSize); }
From source file:com.btbb.figadmin.VanillaBans.java
public static void exportBans(List<EditBan> bans) throws IOException { JsonArray mcbans = new JsonArray(); JsonArray ipbans = new JsonArray(); for (EditBan b : bans) { String created = "", expires = ""; if (b.time > 0) created = mcDateFormat.format(new Date(b.time)); if (b.endTime > 0) expires = mcDateFormat.format(new Date(b.endTime)); if (b.type == EditBan.BanType.IPBAN && b.ipAddress != null) ipbans.add(new IPBan(b.ipAddress, created, b.admin, expires, b.reason).toJson()); if (b.type == EditBan.BanType.BAN || (b.type == EditBan.BanType.IPBAN && b.ipAddress == null)) mcbans.add(new MCBan(b.uuid.toString(), b.name, created, b.admin, expires, b.reason).toJson()); }//from w w w .ja va 2 s .c o m GsonBuilder gsonbuilder = (new GsonBuilder()).setPrettyPrinting(); Gson b = gsonbuilder.create(); String s = b.toJson(mcbans); BufferedWriter bufferedwriter = null; try { bufferedwriter = Files.newWriter(new File("banned-players.json"), Charsets.UTF_8); bufferedwriter.write(s); } finally { IOUtils.closeQuietly(bufferedwriter); s = b.toJson(ipbans); } try { bufferedwriter = Files.newWriter(new File("banned-ips.json"), Charsets.UTF_8); bufferedwriter.write(s); } finally { IOUtils.closeQuietly(bufferedwriter); } }
From source file:ch.wscr.management.WscrManagementApplicationTests.java
@Test public void storeMemberTest() { Member memberToSave = new Member(); memberToSave.setFirstName("Marco"); memberToSave.setLastName("Nitschke"); memberToSave.setBirthDate(new Date(new GregorianCalendar(1977, Calendar.JANUARY, 20).getTimeInMillis())); memberToSave.setAdrStreet("Rilkeweg 9"); memberToSave.setAdrPostalCode("70771"); memberToSave.setAdrCity("Echterdingen"); memberToSave.setDriverLicense(true); memberToSave.setAdrCountry(Country.DE); Member memberSaved = memberRepository.save(memberToSave); assertThat(memberSaved.getMemberId(), is(1)); }
From source file:gov.nih.nci.integration.dao.DefaultIHubMessageDao.java
/** * saveMessage//from www.j a va2 s . c o 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:de.interseroh.report.formatters.DateFormatter.java
@Override public Date parse(String text, Locale locale) throws ParseException { java.util.Date parsed = getDateFormat(locale).parse(text); return new Date(parsed.getTime()); }
From source file:org.apache.hive.storage.jdbc.spitter.DateIntervalSplitter.java
@Override public List<MutablePair<String, String>> getIntervals(String lowerBound, String upperBound, int numPartitions, TypeInfo typeInfo) {// w w w. j a v a 2 s . c o m List<MutablePair<String, String>> intervals = new ArrayList<>(); Date dateLower = Date.valueOf(lowerBound); Date dateUpper = Date.valueOf(upperBound); double dateInterval = (dateUpper.getTime() - dateLower.getTime()) / (double) numPartitions; Date splitDateLower, splitDateUpper; for (int i = 0; i < numPartitions; i++) { splitDateLower = new Date(Math.round(dateLower.getTime() + dateInterval * i)); splitDateUpper = new Date(Math.round(dateLower.getTime() + dateInterval * (i + 1))); if (splitDateLower.compareTo(splitDateUpper) < 0) { intervals .add(new MutablePair<String, String>(splitDateLower.toString(), splitDateUpper.toString())); } } return intervals; }
From source file:com.dianping.lion.dao.ibatis.TeamIbatisDaoTest.java
@Test public void testUpdate() { Team team = new Team(); team.setName("teamx"); team.setCreateTime(new Date(System.currentTimeMillis())); team.setModifyTime(new Date(System.currentTimeMillis())); teamDao.update(team);//from w w w .j a va2 s .c o m }
From source file:com.jaspersoft.jasperserver.war.cascade.handlers.converters.SqlDateDataConverter.java
@Override public Date stringToValue(String rawData) throws ParseException { return StringUtils.isNotEmpty(rawData) ? new Date(dateDataConverter.stringToValue(rawData).getTime()) : null;/*from ww w . jav a 2 s . 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()); }//from ww w . ja va2 s . com 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:fr.xebia.demo.ws.rs.employee.EmployeeService.java
@GET @Path("/employees/{id}/") public Employee getEmployee(@PathParam("id") int id) { Employee employee = new Employee(); employee.setId(id);//from w w w . j a v a 2 s . c om employee.setLastName("Doe"); employee.setFirstName("John"); employee.setGender(Gender.MALE); employee.setBirthdate(new Date(new GregorianCalendar(1976, 01, 05).getTimeInMillis())); logger.info("getEmployee(" + id + "): " + ToStringBuilder.reflectionToString(employee)); return employee; }