List of usage examples for java.sql Date Date
public Date(long date)
From source file:view.PnIncome.java
private void drawDateChartMonth(int month, int year) { ModelCustomerService modelCustomerService = new ModelCustomerService(); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.YEAR, year); int daysOfMonth = calendar.get(Calendar.DAY_OF_MONTH); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); ModelRoomStatus modelRoomStatus = new ModelRoomStatus(); for (int i = 1; i <= daysOfMonth; i++) { calendar.set(Calendar.DAY_OF_MONTH, i); dataset.addValue(/*from w ww. j av a 2 s. c o m*/ modelRoomStatus.getIncomeRoomByDay(new Date(calendar.getTimeInMillis())) + modelCustomerService.getIncomeByDate(new Date(calendar.getTimeInMillis())), "Ngy", String.valueOf(i)); } pnCenter.add(getChartPanel("Thu nhp trong thng", "Thng", dataset), BorderLayout.CENTER); }
From source file:su90.mybatisdemo.dao.Job_HistoryMapperTest.java
@Test(groups = { "find" }) public void testFindByRawProperties01() { try {/*from ww w .j a v a 2s .c o m*/ SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); java.util.Date start_util_date = formatter.parse("20020701"); Job_History search = job_HistoryMapper.findByIdRaw(200L, new Date(start_util_date.getTime())); List<Job_History> result = job_HistoryMapper.findByRawProperties(search); assertEquals(result.size(), 1); assertNotNull(result.get(0)); assertNotNull(result.get(0).getEmployee()); assertNotNull(result.get(0).getJob()); assertNotNull(result.get(0).getDepartment()); } catch (ParseException ex) { assertTrue(false); } }
From source file:org.apache.storm.jdbc.mapper.SimpleJdbcMapper.java
@Override public List<Column> getColumns(ITuple tuple) { List<Column> columns = new ArrayList<Column>(); for (Column column : schemaColumns) { String columnName = column.getColumnName(); Integer columnSqlType = column.getSqlType(); if (Util.getJavaType(columnSqlType).equals(String.class)) { String value = tuple.getStringByField(columnName); columns.add(new Column(columnName, value, columnSqlType)); } else if (Util.getJavaType(columnSqlType).equals(Short.class)) { Short value = tuple.getShortByField(columnName); columns.add(new Column(columnName, value, columnSqlType)); } else if (Util.getJavaType(columnSqlType).equals(Integer.class)) { Integer value = tuple.getIntegerByField(columnName); columns.add(new Column(columnName, value, columnSqlType)); } else if (Util.getJavaType(columnSqlType).equals(Long.class)) { Long value = tuple.getLongByField(columnName); columns.add(new Column(columnName, value, columnSqlType)); } else if (Util.getJavaType(columnSqlType).equals(Double.class)) { Double value = tuple.getDoubleByField(columnName); columns.add(new Column(columnName, value, columnSqlType)); } else if (Util.getJavaType(columnSqlType).equals(Float.class)) { Float value = tuple.getFloatByField(columnName); columns.add(new Column(columnName, value, columnSqlType)); } else if (Util.getJavaType(columnSqlType).equals(Boolean.class)) { Boolean value = tuple.getBooleanByField(columnName); columns.add(new Column(columnName, value, columnSqlType)); } else if (Util.getJavaType(columnSqlType).equals(byte[].class)) { byte[] value = tuple.getBinaryByField(columnName); columns.add(new Column(columnName, value, columnSqlType)); } else if (Util.getJavaType(columnSqlType).equals(Date.class)) { Long value = tuple.getLongByField(columnName); columns.add(new Column(columnName, new Date(value), columnSqlType)); } else if (Util.getJavaType(columnSqlType).equals(Time.class)) { Long value = tuple.getLongByField(columnName); columns.add(new Column(columnName, new Time(value), columnSqlType)); } else if (Util.getJavaType(columnSqlType).equals(Timestamp.class)) { Long value = tuple.getLongByField(columnName); columns.add(new Column(columnName, new Timestamp(value), columnSqlType)); } else {/*from ww w . j a v a 2 s . c o m*/ throw new RuntimeException("Unsupported java type in tuple " + Util.getJavaType(columnSqlType)); } } return columns; }
From source file:tdunnick.jphineas.console.queue.Charts.java
/** * Adds data for one interval in the bar chart. The date is set to MMM-yy * format.// ww w . j a v a2s . c o m * * @param data to add interval to * @param constraints for that data * @param d time (date) for that interval * @param values for each constraint */ private void addBarData(DefaultCategoryDataset data, ArrayList<String> constraints, long d, int[] values) { SimpleDateFormat f = new SimpleDateFormat("MMM-yy"); String date = f.format(new Date(d)); for (int i = 0; i < values.length; i++) { data.addValue(values[i], constraints.get(i), date); values[i] = 0; } }
From source file:com.janoz.tvapilib.thetvdb.impl.EpisodeParser.java
private Date parseDate(String src) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); try {/* w w w.j a v a2 s.c o m*/ return new Date(df.parse(src).getTime()); } catch (ParseException e) { throw new TvApiException("Unable to retreive date from '" + src + "'.", e); } }
From source file:mvc.dao.TarefaDAO.java
public boolean alterarTarefa(Tarefa tarefa) { String sql = "update tarefas set descricao = ?," + " finalizado=?, dataFinalizacao=? where id = ? "; try (PreparedStatement stmt = connection.prepareStatement(sql)) { stmt.setString(1, tarefa.getDescricao()); stmt.setBoolean(2, tarefa.isFinalizado()); if (tarefa.getDataFinalizacao() != null) { stmt.setDate(3, new Date(tarefa.getDataFinalizacao().getTimeInMillis())); } else {/* w w w .j av a2s . c om*/ stmt.setNull(3, java.sql.Types.DATE); } stmt.setLong(4, tarefa.getId()); stmt.execute(); } catch (SQLException e) { throw new RuntimeException(e); } return true; }
From source file:org.beanfuse.security.service.UserServiceImpl.java
public void createGroup(User creator, Group group) { group.setUpdatedAt(new Date(System.currentTimeMillis())); group.setCreatedAt(new Date(System.currentTimeMillis())); group.setCreator(creator);/*from ww w . j a va 2 s . c om*/ // ? creator.getMngGroups().add(group); entityDao.saveOrUpdate(group); entityDao.saveOrUpdate(creator); }
From source file:de.interseroh.report.domain.visitors.RequestParamsBuilderTest.java
private Date fixedDate() { Calendar calendar = Calendar.getInstance(Locale.GERMANY); calendar.set(2015, 8, 5, 21, 12, 23); return new Date(calendar.getTimeInMillis()); }
From source file:com.asakusafw.operation.tools.hadoop.fs.Clean.java
@Override public int run(String[] args) { if (args == null) { throw new IllegalArgumentException("args must not be null"); //$NON-NLS-1$ }//from w w w . j a v a2 s .c o m Opts opts; try { opts = parseOptions(args); if (opts == null) { return 2; } } catch (Exception e) { LOG.error(MessageFormat.format("[OT-CLEAN-E00001] Invalid options: {0}", Arrays.toString(args)), e); return 2; } long period = currentTime - (long) (opts.keepDays * TimeUnit.DAYS.toMillis(1)); if (LOG.isDebugEnabled()) { LOG.debug("Keep switching-time: {}", new Date(period)); //$NON-NLS-1$ } Context context = new Context(opts.recursive, period, opts.dryRun); for (Path path : opts.paths) { remove(path, context); } if (context.hasError()) { return 1; } return 0; }
From source file:org.jumpmind.symmetric.service.impl.AbstractDataExtractorServiceTest.java
@Test public void testExtractOneBatchOneRow() { save(new TestExtract(id++, "abc 123", "abcdefghijklmnopqrstuvwxyz", new Timestamp(System.currentTimeMillis()), new Date(System.currentTimeMillis()), true, Integer.MAX_VALUE, new BigDecimal(Double.toString(Math.PI)))); routeAndCreateGaps();/*from w w w. java 2 s . c o m*/ ExtractResults results = extract(); assertNotNull(results.getBatches()); assertEquals(1, results.getBatches().size()); assertNumberOfLinesThatStartWith(1, "insert,", results.getCsv()); long batchId = results.getBatches().get(0).getBatchId(); assertNumberOfLinesThatStartWith(1, "batch," + batchId, results.getCsv()); assertNumberOfLinesThatStartWith(1, "commit," + batchId, results.getCsv()); assertNumberOfLinesThatStartWith(1, "table," + TEST_TABLE, results.getCsv(), true, false); // same batch should be extracted results = extract(); assertNumberOfLinesThatStartWith(1, "batch," + batchId, results.getCsv()); assertNumberOfLinesThatStartWith(1, "commit," + batchId, results.getCsv()); }