List of usage examples for org.joda.time DateTime getDayOfMonth
public int getDayOfMonth()
From source file:ufjf.GetVideosUFJF.java
public static final Date getDate(String sujeito) throws UnsupportedEncodingException { final String DCTERMS = "<dcterms:date>"; String gsonQodra = requisicaoUFJF(sujeito, DCTERMS); String valores[] = gsonQodra.split("values\":"); DateTime d = DateTime.parse(valores[1].replace("[", "").replaceAll("\"", "").replaceAll("<", "") .replaceAll(">", "").replaceAll("}", "").replaceAll("]]", "")); Calendar c = Calendar.getInstance(); Calendar calendar = Calendar.getInstance(); calendar.set(d.getYear(), d.getMonthOfYear() - 1, d.getDayOfMonth()); return calendar.getTime(); }
From source file:uk.ac.ucl.excites.sapelli.collector.activities.ExportActivity.java
License:Apache License
@SuppressLint("InflateParams") private void setDateRange(final int dtRangeIdx) { // Init current date time to show in dialog: DateTime current = dateRange[dtRangeIdx]; if (current == null) switch (dtRangeIdx) { case DT_RANGE_IDX_FROM: // default "from" time is today at 00:00:00: DateTime now = DateTime.now(); current = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 0, 0); break; case DT_RANGE_IDX_TO: // default "to" time is *now*: current = DateTime.now();//from w ww .j av a2s. c om break; } // UI elements: View view = getLayoutInflater().inflate(R.layout.dialog_datetime, null); final DatePicker datePicker = (DatePicker) view.findViewById(R.id.DTdatePicker); datePicker.updateDate(current.getYear(), current.getMonthOfYear(), current.getDayOfMonth()); final TimePicker timePicker = (TimePicker) view.findViewById(R.id.DTtimePicker); timePicker.setIs24HourView(true); timePicker.setCurrentHour(current.getHourOfDay()); timePicker.setCurrentMinute(current.getMinuteOfHour()); // Create the dialog AlertDialog.Builder builder = new Builder(this); // Set the title: builder.setTitle(getString( dtRangeIdx == DT_RANGE_IDX_FROM ? R.string.exportDateRangeFrom : R.string.exportDateRangeTo, '\u2026')) // Set UI: .setView(view) // Set the buttons: // OK: .setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { updateDateRange(dtRangeIdx, new DateTime(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth(), timePicker.getCurrentHour(), timePicker.getCurrentMinute(), 0, 0)); } }) // Cancel: .setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) // Any time: .setNeutralButton(StringUtils.capitalizeFirstLetter(getString(R.string.exportDateRangeAnytime)), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { updateDateRange(dtRangeIdx, null); // null = *any time* (no limit set) } }) // Create the dialog and show it. .create().show(); }
From source file:uk.ac.ucl.excites.sapelli.collector.fragments.ExportFragment.java
License:Apache License
@SuppressLint("InflateParams") private void setDateRange(final int dtRangeIdx) { // Init current date time to show in dialog: DateTime current = dateRange[dtRangeIdx]; if (current == null) switch (dtRangeIdx) { case DT_RANGE_IDX_FROM: // default "from" time is today at 00:00:00: DateTime now = DateTime.now(); current = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 0, 0); break; case DT_RANGE_IDX_TO: // default "to" time is *now*: current = DateTime.now();/* w w w . j a v a 2s .c om*/ break; } // UI elements: View view = getOwner().getLayoutInflater().inflate(R.layout.dialog_datetime, null); final DatePicker datePicker = (DatePicker) view.findViewById(R.id.DTdatePicker); datePicker.updateDate(current.getYear(), current.getMonthOfYear(), current.getDayOfMonth()); final TimePicker timePicker = (TimePicker) view.findViewById(R.id.DTtimePicker); timePicker.setIs24HourView(true); timePicker.setCurrentHour(current.getHourOfDay()); timePicker.setCurrentMinute(current.getMinuteOfHour()); // Create the dialog AlertDialog.Builder builder = new AlertDialog.Builder(getOwner()); // Set the title: builder.setTitle(getString( dtRangeIdx == DT_RANGE_IDX_FROM ? R.string.exportDateRangeFrom : R.string.exportDateRangeTo, '\u2026')) // Set UI: .setView(view) // Set the buttons: // OK: .setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { updateDateRange(dtRangeIdx, new DateTime(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth(), timePicker.getCurrentHour(), timePicker.getCurrentMinute(), 0, 0)); } }) // Cancel: .setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) // Any time: .setNeutralButton(StringUtils.capitalizeFirstLetter(getString(R.string.exportDateRangeAnytime)), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { updateDateRange(dtRangeIdx, null); // null = *any time* (no limit set) } }) // Create the dialog and show it. .create().show(); }
From source file:uk.co.jassoft.markets.utils.article.ContentGrabber.java
private Date getDateValue(final String contentsToCheck) { if (contentsToCheck.isEmpty()) return null; Parser parser = new Parser(); List<DateGroup> groups = parser.parse(contentsToCheck); Date possibleDate = null;/*from w w w. j a v a 2 s. c o m*/ for (DateGroup group : groups) { List<Date> dates = group.getDates(); for (Date publishedDate : dates) { if (new DateTime(DateTimeZone.UTC).plusDays(1).isBefore(publishedDate.getTime())) { LOG.debug("Date is over 1 day in the future [{}]", publishedDate.toString()); continue; } if (possibleDate == null) { possibleDate = publishedDate; if (group.isTimeInferred()) { possibleDate = new DateTime(publishedDate).withTime(0, 0, 0, 0).toDate(); } continue; } DateTime latestPublishedDate = new DateTime(publishedDate); if (!group.isTimeInferred()) { possibleDate = new DateTime(possibleDate).withTime(latestPublishedDate.getHourOfDay(), latestPublishedDate.getMinuteOfHour(), latestPublishedDate.getSecondOfMinute(), latestPublishedDate.getMillisOfSecond()).toDate(); } if (!group.isDateInferred()) { possibleDate = new DateTime(possibleDate).withDate(latestPublishedDate.getYear(), latestPublishedDate.getMonthOfYear(), latestPublishedDate.getDayOfMonth()).toDate(); } } } if (possibleDate != null) { return possibleDate; } return null; }
From source file:updaters.FeedStatsCalculator.java
License:Open Source License
private static String constructMDYString(DateTime dt) { return dt.getMonthOfYear() + "-" + dt.getDayOfMonth() + "-" + dt.getYear(); }
From source file:ve.zoonosis.controller.seguridad.NuevoUsuarioController.java
License:Apache License
@Override public final void inicializar() { activeInput(false);// www . ja v a 2 s. c om cardNumber.setEnabled(true); if (entity == null) { entity = new Usuario(); limpiar(); buscar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { buscarPersona(); } }); limpiar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { limpiar(); } }); cardNumber.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { buscar.setEnabled(validarCedula()); if (e.getKeyCode() == KeyEvent.VK_ENTER && buscar.isEnabled()) { buscarPersona(); } } }); } else { activeInput(true); persona = entity.getPersona(); permiso.setEnabled(false); buscar.setVisible(false); limpiar.setVisible(false); BindObject bindObject2 = new BindObject(persona); Bindings.bind(cardNumber, bindObject2.getBind("cedula")); Bindings.bind(nombre, bindObject2.getBind("nombre")); Bindings.bind(apellido, bindObject2.getBind("apellido")); } aceptar.setEnabled(false); nombre.setMaxLength(45); apellido.setMaxLength(45); cardNumber.setMaxLength(20); usr.setMaxLength(20); iniForm(); try { rb = new RequestBuilder("services/administracion/PermisoWs/BuscarPermiso.php"); List<Permiso> permisos = rb.ejecutarJson(List.class, Permiso.class); if (permisos != null) { permisos.add(0, null); permiso.setModel(new ListComboBoxModel<>(permisos)); permiso.setSelectedIndex(-1); } } catch (URISyntaxException | RuntimeException ex) { LOG.LOGGER.log(Level.SEVERE, null, ex); } BindObject bindObject2 = new BindObject(entity); Bindings.bind(usr, bindObject2.getBind("nombre")); Bindings.bind(contrasena, bindObject2.getBind("contrasena")); Bindings.bind(fechaNacimiento, bindObject2.getBind("fechaNacimiento"), new SimpleDateFormat("dd/MM/yyyy")); Bindings.bind(permiso, bindObject2.getBind("permiso"), true); autoCreateValidateForm(Persona.class, Usuario.class); repeatPass.addKeyListener(formularioActionListener); usr.addKeyListener(formularioActionListener); DateTime d = new DateTime(); Date dia = new Date(d.getDayOfMonth() + "/" + d.getMonthOfYear() + "/" + (d.getYear() - 18)); fechaNacimiento.setMaxSelectableDate(dia); Date dia2 = new Date(d.getDayOfMonth() + "/" + d.getMonthOfYear() + "/" + (d.getYear() - 80)); fechaNacimiento.setMinSelectableDate(dia2); iniciarDialogo(); }