List of usage examples for java.util Date setSeconds
@Deprecated public void setSeconds(int seconds)
From source file:org.apache.hadoop.hive.ql.udf.UDFNextDay.java
public String evaluate(String date, Integer day) { if (date == null || day == null) { return null; }//w w w . j av a 2s . c o m if (day < 1 || day > 7) { return null; } Pattern pattern = Pattern.compile("([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])[\\s\\S]*(\\..*)?$"); Matcher matcher = pattern.matcher(date); if (!matcher.matches()) { return null; } int year = Integer.valueOf(matcher.group(1)); int month = Integer.valueOf(matcher.group(2)); int dd = Integer.valueOf(matcher.group(3)); Date ret = new Date(); ret.setYear(year - 1900); ret.setMonth(month - 1); ret.setDate(dd); ret.setHours(0); ret.setMinutes(0); ret.setSeconds(0); Calendar curr = Calendar.getInstance(); curr.setTime(ret); int curr_week = curr.get(Calendar.DAY_OF_WEEK); int offset = 7 + (day - curr_week); curr.add(Calendar.DAY_OF_WEEK, offset); Date newDate = curr.getTime(); System.out.println("newDate:" + newDate.toString()); year = curr.get(Calendar.YEAR); month = curr.get(Calendar.MONTH) + 1; dd = curr.get(Calendar.DAY_OF_MONTH); System.out.println("curr.get(Calendar.MONTH):" + curr.get(Calendar.MONTH)); return String.format("%04d-%02d-%02d", year, month, dd); }
From source file:com.dalamar.model.LateTrainDaoImpl.java
private Conjunction createDateCriterion(Date d) { d.setHours(0);// ww w. ja v a 2 s. co m d.setMinutes(0); d.setSeconds(0); Date beginDate = d; Date endDate = new Date(beginDate.getTime() + TimeUnit.DAYS.toMillis(1)); Conjunction andOperator = Restrictions.conjunction(); andOperator.add(Restrictions.ge("dateCaptured", beginDate)); andOperator.add(Restrictions.lt("dateCaptured", endDate)); return andOperator; }
From source file:v2.ClientTest.java
@Test public void testDatesLaptop() throws APIException { Laptop laptop = new Laptop(); laptop.setStatus(Laptop.TAGGED_S0);/* ww w. j a v a 2s .c om*/ Date dateDelivered = new Date(); dateDelivered.setHours(12); dateDelivered.setMinutes(45); dateDelivered.setSeconds(10); dateDelivered.setMonth(3); dateDelivered.setYear(2012); laptop.setDateDelivered(dateDelivered); Date dateReceived = new Date(); dateReceived.setHours(1); dateReceived.setMinutes(41); dateReceived.setSeconds(10); dateReceived.setMonth(5); dateReceived.setYear(2012); laptop.setDateReceived(dateReceived); Date dateRecycled = new Date(); dateRecycled.setHours(1); dateRecycled.setMinutes(35); dateRecycled.setSeconds(10); dateRecycled.setMonth(4); dateRecycled.setYear(2012); laptop.setDateRecycled(dateRecycled); String nid = client.addLaptop(laptop); // Check date laptop // Laptop laptop = client.getLaptop(nid); // log.info(laptop); // log.info("Response test: "+nid); boolean result = client.deleteLaptop(nid); // log.info("It was deleted: "+result); Assert.assertTrue(result); }
From source file:com.dalamar.model.LateTrainDaoImpl.java
private Conjunction createDateCriterion(Date begin, Date end) { begin.setHours(0);/*from w ww . ja va 2 s . c om*/ begin.setMinutes(0); begin.setSeconds(0); end.setHours(0); end.setMinutes(0); end.setSeconds(0); Date beginDate = begin; Date endDate = new Date(end.getTime() + TimeUnit.DAYS.toMillis(1)); Conjunction andOperator = Restrictions.conjunction(); andOperator.add(Restrictions.ge("dateCaptured", beginDate)); andOperator.add(Restrictions.lt("dateCaptured", endDate)); return andOperator; }
From source file:br.com.hslife.orcamento.task.AgendamentoTask.java
@Scheduled(fixedDelay = 3600000) @SuppressWarnings("deprecation") public void enviarEmailNotificacao() { try {/*from www . j av a2 s.co m*/ Date inicio = new Date(); inicio.setHours(0); inicio.setMinutes(0); inicio.setSeconds(0); Date fim = new Date(inicio.getTime()); fim.setHours(23); fim.setMinutes(59); fim.setSeconds(59); List<Agenda> agendamentos = getService().buscarAgendamentoPorOuDataInicioOuDataFimEAlerta(inicio, fim, true); // Itera a lista de agendamentos encontrados, e para cada uma envia um e-mail para o usurio for (Agenda a : agendamentos) { // Se o usurio marcou para no receber notificao o e-mail no ser enviado if (getOpcaoSistemaComponent().getNotificarAgendamentosEmail(a.getUsuario())) { StringBuilder mensagemEmail = new StringBuilder(); mensagemEmail.append("Prezado " + a.getUsuario().getNome() + ",\n\n"); mensagemEmail.append("O seguinte agendamento foi marcado para notific-lo:\n\n"); mensagemEmail.append(a.getDescricao() + "\n"); mensagemEmail.append("Tipo: " + a.getTipoAgendamento() + "\n"); mensagemEmail.append("Perodo: \n" + a.getDateLabel() + "\n"); mensagemEmail.append("Dia inteiro: " + (a.isDiaInteiro() ? "SIM" : "NO") + "\n"); mensagemEmail.append("Notas: " + (a.getNotas() == null ? "-" : a.getNotas()) + "\n\n"); mensagemEmail.append( "Caso no queira mais receber notificaes a respeito desse evento, desmarque a caixa 'Emitir Alerta' nas propriedades do agendamento.\n\n\n"); mensagemEmail.append("Administrador do Sistema"); emailComponent.setDestinatario(a.getUsuario().getNome()); emailComponent.setEmailDestinatario(a.getUsuario().getEmail()); emailComponent.setAssunto("Oramento Domstico - Lembrete de agendamento"); emailComponent.setMensagem(mensagemEmail.toString()); emailComponent.enviarEmail(); } } } catch (Exception e) { logger.catching(e); e.printStackTrace(); } }
From source file:de.janrenz.app.mediathek.RemoteImageCursorAdapter.java
@SuppressWarnings("deprecation") @Override//from w w w . j a v a2 s .c o m public void bindView(View v, Context context, Cursor c) { String title = c.getString(c.getColumnIndexOrThrow("title")); String subtitle = c.getString(c.getColumnIndexOrThrow("subtitle")); String imagePath = c.getString(c.getColumnIndexOrThrow("image")); String startTime = c.getString(c.getColumnIndexOrThrow("startTime")); String startTimeAsTimestamp = c.getString(c.getColumnIndex("startTimeAsTimestamp")); String isLive = c.getString(c.getColumnIndex("isLive")); if (this.layout == R.layout.headline_item_grid) { final View vl = v; v.findViewById(R.id.thumbnail).getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { try { View imgView = vl.findViewById(R.id.thumbnail); imgView.getViewTreeObserver().removeGlobalOnLayoutListener(this); ViewGroup.LayoutParams layout = imgView.getLayoutParams(); layout.height = imgView.getWidth() / 16 * 9; imgView.setLayoutParams(layout); } catch (Exception e) { } } }); } /** * Next set the text of the entry. */ if (isLive.equalsIgnoreCase("true")) { v.findViewById(R.id.live).setVisibility(View.VISIBLE); //v.setBackgroundColor( context.getResources().getColor(R.color.highlight_live_list)); } else { v.findViewById(R.id.live).setVisibility(View.GONE); //v.setBackgroundColor( context.getResources().getColor(R.color.list_background)); } TextView title_text = (TextView) v.findViewById(R.id.text_view); if (title_text != null) { title_text.setText(title); } TextView subtitle_text = (TextView) v.findViewById(R.id.text_view_sub); if (subtitle_text != null) { subtitle_text.setText(subtitle); } TextView subtitle2_text = (TextView) v.findViewById(R.id.text_view_sub2); if (subtitle2_text != null) { Date dt = new Date(); // z.B. 'Fri Jan 26 19:03:56 GMT+01:00 2001' dt.setTime(Integer.parseInt(startTimeAsTimestamp) * 1000); dt.setHours(0); dt.setMinutes(0); dt.setSeconds(0); subtitle2_text.setText("ARD > " + startTime + " Uhr"); } /** * Set the image */ DisplayImageOptions loadingOptions = new DisplayImageOptions.Builder() ///.showStubImage(R.drawable.abs__item_background_holo_light) //.imageScaleType(ImageScaleType.EXACTLY) // .showImageForEmptyUri(R.drawable.ic_empty) // .memoryCache(new WeakMemoryCache()) .cacheInMemory() //.cacheOnDisc() .build(); ImageView image_view = (ImageView) v.findViewById(R.id.thumbnail); if (image_view != null) { if (this.layout == R.layout.headline_item_grid) { imagePath = imagePath + "/" + 320; } else { imagePath = imagePath + "/" + 150; } ImageLoader.getInstance().displayImage(imagePath, image_view, loadingOptions); } }
From source file:de.forsthaus.webui.calendar.CalendarCreateEventCtrl.java
/** * Saves the data of an CalendarEvent and closes the window. * /*from www . j av a 2 s. c om*/ * @param event */ public void doSave(Event event) { Calendars cals = getCalendarCtrl().getCal(); MySimpleCalendarEvent ce = new MySimpleCalendarEvent(); Calendar cal = Calendar.getInstance(cals.getDefaultTimeZone()); Date beginDate = ppbegin.getValue(); Date endDate = ppend.getValue(); beginDate.setSeconds(0); endDate.setSeconds(0); if (!ppallDay.isChecked()) { String[] times = ppbt.getSelectedItem().getLabel().split(":"); cal.setTime(beginDate); cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(times[0])); cal.set(Calendar.MINUTE, Integer.parseInt(times[1])); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); beginDate = cal.getTime(); times = ppet.getSelectedItem().getLabel().split(":"); cal.setTime(endDate); cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(times[0])); cal.set(Calendar.MINUTE, Integer.parseInt(times[1])); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); endDate = cal.getTime(); } if (!beginDate.before(endDate)) { alert("The end date cannot be before/equal than begin date!"); return; } String[] colors = ((String) ppcolor.getSelectedItem().getValue()).split(","); ce.setHeaderColor(colors[0]); ce.setContentColor(colors[1]); ce.setBeginDate(beginDate); ce.setEndDate(endDate); ce.setTitle(txtb_title.getValue()); ce.setContent(ppcnt.getValue()); ce.setLocked(pplocked.isChecked()); getCalendarCtrl().getCalModel().add(ce); ppcnt.setRawValue(""); ppbt.setSelectedIndex(0); ppet.setSelectedIndex(0); final SecUser user = ((UserImpl) SecurityContextHolder.getContext().getAuthentication().getPrincipal()) .getSecUser(); // prepare the backend Bean MyCalendarEvent calEvt = getCalendarEventService().getNewCalendarEvent(); calEvt.setSecUser(user); calEvt.setTitle(ce.getTitle()); calEvt.setContent(ce.getContent()); calEvt.setBeginDate(ce.getBeginDate()); calEvt.setEndDate(ce.getEndDate()); calEvt.setHeaderColor(colors[0]); calEvt.setContentColor(ce.getContentColor()); // Save the calendar event to database try { getCalendarEventService().saveOrUpdate(calEvt); syncModel(); } catch (Exception e) { e.printStackTrace(); } createEventWindow.onClose(); }
From source file:de.fahrgemeinschaft.FahrgemeinschaftConnector.java
@SuppressWarnings("deprecation") private Ride parseRide(JSONObject json) throws JSONException { Ride ride = new Ride().type(Ride.OFFER).mode(Mode.CAR); if (startDate == null) ride.marked(); // myrides ride.who(json.getString(ID_USER));//from w w w . ja va 2 s .co m String value = json.getString(CONTACTMAIL); if (!value.equals(EMPTY) && !value.equals(NULL)) ride.set(EMAIL, value); value = json.getString(CONTACTMOBILE); if (!value.equals(EMPTY) && !value.equals(NULL)) ride.set(MOBILE, value); value = json.getString(CONTACTLANDLINE); if (!value.equals(EMPTY) && !value.equals(NULL)) ride.set(LANDLINE, value); value = json.getString(PLATE); if (!value.equals(EMPTY) && !value.equals(NULL)) { ride.set(PLATE, value); if (value.equals(BAHN)) ride.mode(Mode.TRAIN); } ride.getDetails().put(PRIVACY, json.getJSONObject(PRIVACY)); ride.set(COMMENT, json.getString(DESCRIPTION)); if (json.getInt(RELEVANCE) == 10) { ride.activate(); } else { ride.deactivate(); } ride.ref(json.getString(TRIP_ID)); ride.seats(json.getInt(PLACES)); if (!json.isNull(PRICE)) { ride.price((int) Double.parseDouble(json.getString(PRICE)) * 100); } else { ride.price(-1); } JSONObject reoccur = json.getJSONObject(REOCCUR); boolean isReoccuring = isReoccuring(reoccur); boolean isMyride = startDate == null; String time = parseTime(json); if (isReoccuring) { ride.getDetails().put(REOCCUR, reoccur); } if (isReoccuring && isMyride) { ride.type(TYPE_OFFER_REOCCURING); } if (isMyride) { if (time.equals(EMPTY)) { Date date = parseDate(json.getString(STARTDATE) + NOTIME); date.setSeconds(59); ride.dep(date); } else { ride.dep(parseDate(json.getString(STARTDATE) + time)); } } else { if (time.equals(EMPTY)) { Date date = parseDate(startDate + NOTIME); date.setSeconds(59); ride.dep(date); } else { ride.dep(parseDate(startDate + time)); } } JSONArray routings = json.getJSONArray(ROUTINGS); ride.from(store(parsePlace(routings.getJSONObject(0).getJSONObject(ORIGIN)))); for (int j = 1; j < routings.length(); j++) { ride.via(store(parsePlace(routings.getJSONObject(j).getJSONObject(DESTINATION)))); } ride.to(store(parsePlace(routings.getJSONObject(0).getJSONObject(DESTINATION)))); return ride; }
From source file:com.daphne.es.personal.calendar.web.controller.CalendarController.java
@RequestMapping("/load") @ResponseBody/*from w w w.j a va 2s . com*/ public Collection<Map> ajaxLoad(Searchable searchable, @CurrentUser User loginUser) { searchable.addSearchParam("userId_eq", loginUser.getId()); List<Calendar> calendarList = calendarService.findAllWithNoPageNoSort(searchable); return Lists.<Calendar, Map>transform(calendarList, new Function<Calendar, Map>() { @Override public Map apply(Calendar c) { Map<String, Object> m = Maps.newHashMap(); Date startDate = new Date(c.getStartDate().getTime()); Date endDate = DateUtils.addDays(startDate, c.getLength() - 1); boolean allDays = c.getStartTime() == null && c.getEndTime() == null; if (!allDays) { startDate.setHours(c.getStartTime().getHours()); startDate.setMinutes(c.getStartTime().getMinutes()); startDate.setSeconds(c.getStartTime().getSeconds()); endDate.setHours(c.getEndTime().getHours()); endDate.setMinutes(c.getEndTime().getMinutes()); endDate.setSeconds(c.getEndTime().getSeconds()); } m.put("id", c.getId()); m.put("start", DateFormatUtils.format(startDate, "yyyy-MM-dd HH:mm:ss")); m.put("end", DateFormatUtils.format(endDate, "yyyy-MM-dd HH:mm:ss")); m.put("allDay", allDays); m.put("title", c.getTitle()); m.put("details", c.getDetails()); if (StringUtils.isNotEmpty(c.getBackgroundColor())) { m.put("backgroundColor", c.getBackgroundColor()); m.put("borderColor", c.getBackgroundColor()); } if (StringUtils.isNotEmpty(c.getTextColor())) { m.put("textColor", c.getTextColor()); } return m; } }); }
From source file:com.framework.demo.web.controller.calendar.CalendarController.java
@RequestMapping("/load") @ResponseBody//from w w w. j av a 2 s . c om public Collection<Map> ajaxLoad(Searchable searchable, @CurrentUser SysUser loginUser) { searchable.addSearchParam("userId_eq", loginUser.getId()); List<PersonalCalendar> calendarList = calendarService.findAllWithNoPageNoSort(searchable); return Lists.<PersonalCalendar, Map>transform(calendarList, new Function<PersonalCalendar, Map>() { public Map apply(PersonalCalendar c) { Map<String, Object> m = Maps.newHashMap(); Date startDate = new Date(c.getStartDate().getTime()); Date endDate = DateUtils.addDays(startDate, c.getLength() - 1); boolean allDays = c.getStartTime() == null && c.getEndTime() == null; if (!allDays) { startDate.setHours(c.getStartTime().getHours()); startDate.setMinutes(c.getStartTime().getMinutes()); startDate.setSeconds(c.getStartTime().getSeconds()); endDate.setHours(c.getEndTime().getHours()); endDate.setMinutes(c.getEndTime().getMinutes()); endDate.setSeconds(c.getEndTime().getSeconds()); } m.put("id", c.getId()); m.put("start", DateFormatUtils.format(startDate, "yyyy-MM-dd HH:mm:ss")); m.put("end", DateFormatUtils.format(endDate, "yyyy-MM-dd HH:mm:ss")); m.put("allDay", allDays); m.put("title", c.getTitle()); m.put("details", c.getDetails()); if (StringUtils.isNotEmpty(c.getBackgroundColor())) { m.put("backgroundColor", c.getBackgroundColor()); m.put("borderColor", c.getBackgroundColor()); } if (StringUtils.isNotEmpty(c.getTextColor())) { m.put("textColor", c.getTextColor()); } return m; } }); }