List of usage examples for org.joda.time DateTime getYear
public int getYear()
From source file:adwords.axis.v201502.advancedoperations.AddAdCustomizer.java
License:Open Source License
/** * Creates FeedItems with the values to use in ad customizations for each ad group in * <code>adGroupIds</code>.// w ww. j a va2 s.co m */ private static void createCustomizerFeedItems(AdWordsServices adWordsServices, AdWordsSession session, List<Long> adGroupIds, AdCustomizerFeed adCustomizerFeed) throws Exception { // Get the FeedItemService. FeedItemServiceInterface feedItemService = adWordsServices.get(session, FeedItemServiceInterface.class); List<FeedItemOperation> feedItemOperations = Lists.newArrayList(); DateTime now = new DateTime(); DateTime marsDate = new DateTime(now.getYear(), now.getMonthOfYear(), 1, 0, 0); feedItemOperations.add(createFeedItemAddOperation("Mars", "$1234.56", marsDate.toString("yyyyMMdd HHmmss"), adGroupIds.get(0), adCustomizerFeed)); DateTime venusDate = new DateTime(now.getYear(), now.getMonthOfYear(), 15, 0, 0); feedItemOperations.add(createFeedItemAddOperation("Venus", "$1450.00", venusDate.toString("yyyyMMdd HHmmss"), adGroupIds.get(1), adCustomizerFeed)); FeedItemReturnValue feedItemReturnValue = feedItemService .mutate(feedItemOperations.toArray(new FeedItemOperation[feedItemOperations.size()])); for (FeedItem addedFeedItem : feedItemReturnValue.getValue()) { System.out.printf("Added feed item with ID %d.%n", addedFeedItem.getFeedItemId()); } }
From source file:aplicacion.control.EmpleadoController.java
public void setEmpleado(Usuario empleado) throws IOException, SQLException { this.empleado = empleado; nombre.setText(empleado.getNombre() + " " + empleado.getApellido()); cedula.setText(empleado.getCedula()); telefono.setText(empleado.getTelefono()); direccion.setText(empleado.getDireccion()); email.setText(empleado.getEmail());/*from w ww .ja v a2s. c o m*/ estadoCivil.setText(empleado.getEstadoCivil().getNombre()); empresa.setText(empleado.getDetallesEmpleado().getEmpresa().getNombre()); departamento.setText(empleado.getDetallesEmpleado().getDepartamento().getNombre()); cargo.setText(empleado.getDetallesEmpleado().getCargo().getNombre()); cuenta.setText(empleado.getDetallesEmpleado().getNroCuenta()); sueldo.setText("$" + empleado.getDetallesEmpleado().getSueldo()); extra.setText(empleado.getDetallesEmpleado().getExtra()); DateTime inicio = new DateTime(empleado.getDetallesEmpleado().getFechaInicio().getTime()); fechaInicio.setText( inicio.getDayOfMonth() + " de " + getMonthName(inicio.getMonthOfYear()) + " " + inicio.getYear()); DateTime contrato = new DateTime(empleado.getDetallesEmpleado().getFechaContrato().getTime()); fechaContrato.setText(contrato.getDayOfMonth() + " de " + getMonthName(contrato.getMonthOfYear()) + " " + contrato.getYear()); DateTime nacimiento = new DateTime(empleado.getNacimiento().getTime()); cumpleano.setText(nacimiento.getDayOfMonth() + " de " + getMonthName(nacimiento.getMonthOfYear()) + " " + nacimiento.getYear()); Foto foto = new FotoDAO().findByEmpleadoId(empleado.getId()); if (foto != null && foto.getFoto() != null) { final BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream(foto.getFoto())); Image image = SwingFXUtils.toFXImage(bufferedImage, null); setProfileImage(image); } }
From source file:aplicacion.control.HorarioEmpleadoController.java
public static LocalDate getDateFromTimestamp(Timestamp timestamp) { if (timestamp == null) { return null; } else {/*w w w . j ava 2 s . c o m*/ DateTime dateTime = new DateTime(timestamp.getTime()); return LocalDate.of(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth()); } }
From source file:aplicacion.control.util.Fechas.java
public static LocalDate getLocalFromTimestamp(Timestamp timestamp) { if (timestamp == null) { return null; } else {//w w w. j a v a2s .c o m DateTime dateTime = new DateTime(timestamp.getTime()); return LocalDate.of(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth()); } }
From source file:aplicacion.control.util.Fechas.java
public static String getFechaConMes(DateTime dateTime) { String fecha = dateTime.getDayOfMonth() + " de " + getMonthName(dateTime.getMonthOfYear()) + " " + dateTime.getYear(); return fecha; }
From source file:aplicacion.control.util.Fechas.java
public static String getFechaConMes(Date date) { DateTime dateTime = new DateTime(date.getTime()); String fecha = dateTime.getDayOfMonth() + " de " + getMonthName(dateTime.getMonthOfYear()) + " " + dateTime.getYear(); return fecha; }
From source file:aplicacion.control.util.Fechas.java
public static String getFechaConMes(Timestamp timestamp) { DateTime dateTime = new DateTime(timestamp.getTime()); String fecha = dateTime.getDayOfMonth() + " de " + getMonthName(dateTime.getMonthOfYear()) + " " + dateTime.getYear(); return fecha; }
From source file:aplicacion.control.util.Fechas.java
public static String getFechaConMesYHora(DateTime dateTime) { String fecha = dateTime.getDayOfMonth() + " de " + getMonthName(dateTime.getMonthOfYear()) + " " + dateTime.getYear() + " a las " + dateTime.toString("HH:mm:ss"); return fecha; }
From source file:aplicacion.control.util.Fechas.java
public static String getFechaConMesYHora(Timestamp timestamp) { DateTime dateTime = new DateTime(timestamp.getTime()); String fecha = dateTime.getDayOfMonth() + " de " + getMonthName(dateTime.getMonthOfYear()) + " " + dateTime.getYear() + " a las " + dateTime.toString("HH:mm:ss"); return fecha; }
From source file:app.rappla.calendar.Date.java
License:Open Source License
/** * Constructor//from ww w . j a v a 2 s . co m * * @param icalStr * One or more lines of iCalendar that specifies a date * @param parseMode * PARSE_STRICT or PARSE_LOOSE */ public Date(String icalStr) throws ParseException, BogusDataException { super(icalStr); year = month = day = 0; hour = minute = second = 0; for (int i = 0; i < attributeList.size(); i++) { Attribute a = attributeAt(i); String aname = a.name.toUpperCase(Locale.ENGLISH); String aval = a.value.toUpperCase(Locale.ENGLISH); // TODO: not sure if any attributes are allowed here... // Look for VALUE=DATE or VALUE=DATE-TIME // DATE means untimed for the event if (aname.equals("VALUE")) { if (aval.equals("DATE")) { dateOnly = true; } else if (aval.equals("DATE-TIME")) { dateOnly = false; } } else if (aname.equals("TZID")) { tzid = a.value; } else { // TODO: anything else allowed here? } } String inDate = value; if (inDate.length() < 8) { // Invalid format throw new ParseException("Invalid date format '" + inDate + "'", inDate); } // Make sure all parts of the year are numeric. for (int i = 0; i < 8; i++) { char ch = inDate.charAt(i); if (ch < '0' || ch > '9') { throw new ParseException("Invalid date format '" + inDate + "'", inDate); } } year = Integer.parseInt(inDate.substring(0, 4)); month = Integer.parseInt(inDate.substring(4, 6)); day = Integer.parseInt(inDate.substring(6, 8)); if (day < 1 || day > 31 || month < 1 || month > 12) throw new BogusDataException("Invalid date '" + inDate + "'", inDate); // Make sure day of month is valid for specified month if (year % 4 == 0) { // leap year if (day > leapMonthDays[month - 1]) { throw new BogusDataException("Invalid day of month '" + inDate + "'", inDate); } } else { if (day > monthDays[month - 1]) { throw new BogusDataException("Invalid day of month '" + inDate + "'", inDate); } } // TODO: parse time, handle localtime, handle timezone if (inDate.length() > 8) { // TODO make sure dateOnly == false if (inDate.charAt(8) == 'T') { try { hour = Integer.parseInt(inDate.substring(9, 11)); minute = Integer.parseInt(inDate.substring(11, 13)); second = Integer.parseInt(inDate.substring(13, 15)); if (hour > 23 || minute > 59 || second > 59) { throw new BogusDataException("Invalid time in date string '" + inDate + "'", inDate); } if (inDate.length() > 15) { isUTC = inDate.charAt(15) == 'Z'; } } catch (NumberFormatException nef) { throw new BogusDataException("Invalid time in date string '" + inDate + "' - " + nef, inDate); } } else { // Invalid format throw new ParseException("Invalid date format '" + inDate + "'", inDate); } } else { // Just date, no time dateOnly = true; } if (isUTC && !dateOnly) { // Use Joda Time to convert UTC to localtime DateTime utcDateTime = new DateTime(DateTimeZone.UTC); utcDateTime = utcDateTime.withDate(year, month, day).withTime(hour, minute, second, 0); DateTime localDateTime = utcDateTime.withZone(DateTimeZone.getDefault()); year = localDateTime.getYear(); month = localDateTime.getMonthOfYear(); day = localDateTime.getDayOfMonth(); hour = localDateTime.getHourOfDay(); minute = localDateTime.getMinuteOfHour(); second = localDateTime.getSecondOfMinute(); } else if (tzid != null) { DateTimeZone tz = DateTimeZone.forID(tzid); if (tz != null) { // Convert to localtime DateTime utcDateTime = new DateTime(tz); utcDateTime = utcDateTime.withDate(year, month, day).withTime(hour, minute, second, 0); DateTime localDateTime = utcDateTime.withZone(DateTimeZone.getDefault()); year = localDateTime.getYear(); month = localDateTime.getMonthOfYear(); day = localDateTime.getDayOfMonth(); hour = localDateTime.getHourOfDay(); minute = localDateTime.getMinuteOfHour(); second = localDateTime.getSecondOfMinute(); // Since we have converted to localtime, remove the TZID // attribute this.removeNamedAttribute("TZID"); } } isUTC = false; // Add attribute that says date-only or date with time if (dateOnly) addAttribute("VALUE", "DATE"); else addAttribute("VALUE", "DATE-TIME"); }