List of usage examples for org.joda.time LocalDate getYear
public int getYear()
From source file:com.helger.datetime.holiday.CalendarUtil.java
License:Apache License
/** * Searches for the occurrences of a month/day in one chronology within one * gregorian year./*from www . j a va2s . co m*/ * * @param nTargetMonth * Target month * @param nTargetDay * Target day * @param nGregorianYear * Gregorian year * @param aTargetChronoUTC * Target chronology * @return the list of gregorian dates. */ @Nonnull public static Set<LocalDate> getDatesFromChronologyWithinGregorianYear(final int nTargetMonth, final int nTargetDay, final int nGregorianYear, final Chronology aTargetChronoUTC) { final Set<LocalDate> aHolidays = new HashSet<LocalDate>(); final LocalDate aFirstGregorianDate = PDTFactory.createLocalDate(nGregorianYear, DateTimeConstants.JANUARY, 1); final LocalDate aLastGregorianDate = PDTFactory.createLocalDate(nGregorianYear, DateTimeConstants.DECEMBER, 31); final LocalDate aFirstTargetDate = new LocalDate( aFirstGregorianDate.toDateTimeAtStartOfDay(PDTConfig.getDateTimeZoneUTC()).getMillis(), aTargetChronoUTC); final LocalDate aLastTargetDate = new LocalDate( aLastGregorianDate.toDateTimeAtStartOfDay(PDTConfig.getDateTimeZoneUTC()).getMillis(), aTargetChronoUTC); final Interval aInterv = new Interval( aFirstTargetDate.toDateTimeAtStartOfDay(PDTConfig.getDateTimeZoneUTC()), aLastTargetDate.plusDays(1).toDateTimeAtStartOfDay(PDTConfig.getDateTimeZoneUTC())); for (int nTargetYear = aFirstTargetDate.getYear(); nTargetYear <= aLastTargetDate .getYear(); ++nTargetYear) { final LocalDate aLocalDate = new LocalDate(nTargetYear, nTargetMonth, nTargetDay, aTargetChronoUTC); if (aInterv.contains(aLocalDate.toDateTimeAtStartOfDay(PDTConfig.getDateTimeZoneUTC()))) { aHolidays.add(convertToGregorianDate(aLocalDate)); } } return aHolidays; }
From source file:com.helger.datetime.holiday.mgr.AbstractHolidayManager.java
License:Apache License
@Nonnull private static String _getKey(@Nonnull final LocalDate aDate, @Nullable final String... aArgs) { String sKey = Integer.toString(aDate.getYear()); if (ArrayHelper.isNotEmpty(aArgs)) { final StringBuilder aKey = new StringBuilder(sKey); for (final String sArg : aArgs) aKey.append('_').append(sArg); sKey = aKey.toString();/*from w w w. j a v a2s. c om*/ } return sKey; }
From source file:com.helger.datetime.holiday.mgr.AbstractHolidayManager.java
License:Apache License
@Nullable public ISingleHoliday getHoliday(@Nonnull final LocalDate aDate, @Nullable final String... aArgs) { if (aDate == null) throw new NullPointerException("date"); final String sKey = _getKey(aDate, aArgs); HolidayMap aHolidayMap = m_aHolidaysPerYear.get(sKey); if (aHolidayMap == null) { aHolidayMap = getHolidays(aDate.getYear(), aArgs); m_aHolidaysPerYear.put(sKey, aHolidayMap); }//from w ww . j av a 2 s. c om return aHolidayMap.getHolidayForDate(aDate); }
From source file:com.helger.datetime.PDTFactory.java
License:Apache License
@Nonnull public static LocalDateTime createLocalDateTime(@Nonnull final LocalDate aDate) { return createLocalDateTime(aDate.getYear(), aDate.getMonthOfYear(), aDate.getDayOfMonth()); }
From source file:com.helger.datetime.PDTFactory.java
License:Apache License
@Nonnull public static LocalDateTime createLocalDateTime(@Nonnull final LocalDate aDate, final int nHours, final int nMinutes) { return createLocalDateTime(aDate.getYear(), aDate.getMonthOfYear(), aDate.getDayOfMonth(), nHours, nMinutes, 0, 0);// ww w . j av a 2 s . co m }
From source file:com.helger.datetime.PDTFactory.java
License:Apache License
@Nonnull public static LocalDateTime createLocalDateTime(@Nonnull final LocalDate aDate, final int nHours, final int nMinutes, final int nSeconds) { return createLocalDateTime(aDate.getYear(), aDate.getMonthOfYear(), aDate.getDayOfMonth(), nHours, nMinutes, nSeconds, 0);/* www.j a v a 2 s .co m*/ }
From source file:com.helger.datetime.PDTFactory.java
License:Apache License
@Nonnull public static LocalDateTime createLocalDateTime(@Nonnull final LocalDate aDate, final int nHours, final int nMinutes, final int nSeconds, final int nMilliSeconds) { return createLocalDateTime(aDate.getYear(), aDate.getMonthOfYear(), aDate.getDayOfMonth(), nHours, nMinutes, nSeconds, nMilliSeconds);// w w w. j av a 2s . c o m }
From source file:com.helger.datetime.xml.PDTXMLConverter.java
License:Apache License
/** * Get the passed object as {@link XMLGregorianCalendar} date (without a * time)./* w ww. j a v a 2 s . com*/ * * @param aBase * The source object. May be <code>null</code>. * @return <code>null</code> if the parameter is <code>null</code>. */ @Nullable public static XMLGregorianCalendar getXMLCalendarDate(@Nullable final LocalDate aBase) { return aBase == null ? null : s_aDTFactory.newXMLGregorianCalendarDate(aBase.getYear(), aBase.getMonthOfYear(), aBase.getDayOfMonth(), DatatypeConstants.FIELD_UNDEFINED); }
From source file:com.ideaspymes.arthyweb.ventas.service.impl.GestionComercialService.java
public static String getConsultaCantidadCajasAcum(Integer vendedorId, String bd) { LocalDate localDate = new LocalDate(); int ultimoDia = localDate.dayOfMonth().getMaximumValue(); int mes = localDate.getMonthOfYear(); int anio = localDate.getYear(); return "select sum(x.cant_caja) from \n" + "(SELECT \n" + " FD.[ID Sucursales] as sucursal_key\n" + " ,FD.[ID Vendedores] as cod_vendedor --\n" + " ,FD.[ID Comprobantes Ventas] as comprobante\n" + " ,FD.[Numero] as numero_fac\n" + " ,FD.[ID Linea] as linea_fac \n" + " ,DATEADD(dd, 0, DATEDIFF(dd, 0, F.[Fecha])) as fecha_key\n" + " ,F.[ID Clientes] as cod_cliente --\n" + " ,(SELECT \n" + " --OBTENEMOS LA DESCRIPCION DE LA ZONA EN LA QUE SE EJECUTO LA VENTA\n" + " CASE WHEN [Clasificacion 8] = '1' OR [Clasificacion 8] IS NULL THEN 'NO DEFINIDO' ELSE [Clasificacion 8] END\n" + " " + bd + ".FROM [VTA_Clientes] C WHERE C.[ID Clientes]=F.[ID Clientes] AND C.[ID Sucursales] = FD.[ID Sucursales]) as zona_desc,\n" + " --OBTENEMOS LA DESCRIPCION EL TERRITORIO EN LA QUE SE EJECUTO LA VENTA\n" + " (SELECT \n" + " CASE WHEN [Clasificacion 2] = '1' OR [Clasificacion 2] IS NULL THEN 'NO DEFINIDO' ELSE [Clasificacion 2] END\n" + " " + bd + ".FROM [VTA_Clientes] C WHERE C.[ID Clientes]=F.[ID Clientes] AND C.[ID Sucursales] = FD.[ID Sucursales]) as territorio_desc\n" + " ,FD.[ID Productos] as cod_producto --\n" + " ,FD.[ID Unidades Medidas] as unidad_key\n" + " ,FD.[Cantidad Envase] as cantidad_envase\n" + " ,FD.[Total Linea ML] as importe \n" + " ,ISNULL (CAST (FD.[Promocion] AS INT),0) as bonicicacion\n" + " ,ISNULL (FD.[PromoPLM3] ,0) as cantidad_promo\n" + " ,(CASE WHEN FD.[PromoId]=0 THEN NULL ELSE FD.[PromoId] END) as promo_key\n" + " --CALCULOS PARA OBTENER VOLUMENES DE VENTA POR CAJAS,GRUESAS Y CAJETILLAS\n" + " ,CAST (case when U.[ID Unidades Medidas] = 15 then cast (FD.[Cantidad Envase] as numeric(14,3)) / 50 else (case when U.[ID Unidades Medidas] = 25 then cast (FD.[Cantidad Envase] as numeric(14,3)) / calc.cantidad_caje_por_gruesa / 50 else (case when U.[ID Unidades Medidas] <> 16 then 0 else FD.[Cantidad Envase] end) end ) end AS numeric (14,3) ) as cant_caja\n" + "\n" + " ,CAST ( case when U.[ID Unidades Medidas] = 16 then cast (FD.[Cantidad Envase] as numeric(14,3)) * 50 else (case when U.[ID Unidades Medidas] = 25 then cast (FD.[Cantidad Envase] as numeric(14,3)) / calc.cantidad_caje_por_gruesa else (case when U.[ID Unidades Medidas] <> 15 then 0 else FD.[Cantidad Envase] end) end ) end AS numeric (14,3) )as cant_gruesa\n" + "\n" + " ,CAST (case when U.[ID Unidades Medidas] <> 29 then cast (FD.[Cantidad Envase] as numeric(14,3)) * U.[Cantidad] else 0 end AS numeric (14,3) )as cant_cajetilla\n" + " \n" + "FROM " + bd + ".[VTA_D Comprobantes de Ventas] FD WITH (NOLOCK)\n" + "INNER JOIN " + bd + ".[VTA_C Comprobantes de Ventas] F WITH (NOLOCK) \n" + " ON FD.Origen = F.Origen \n" + " AND FD.[ID Sucursales] = F.[ID Sucursales] \n" + " AND FD.[ID Vendedores] = F.[ID Vendedores] \n" + " AND FD.[ID Comprobantes Ventas] = F.[ID Comprobantes Ventas] \n" + " AND FD.numero = F.numero\n" + "--\n" + "LEFT JOIN " + bd + ".[STK_UM de Productos] U WITH (NOLOCK)\n" + " ON FD.[ID Unidades Medidas] = U.[ID Unidades Medidas]\n" + " AND FD.[ID Productos] = U.[ID Productos]\n" + "-- TABLA VIRTUAL PARA OBTENER CANTIDA DE PABILOS POR CAJETILLA\n" + "LEFT JOIN " + bd + ".calc_pabilo calc ON FD.[ID Productos] = calc.[ID Productos]\n" + "WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, F.[Fecha])) between " + convertFechaSQL(1, mes, anio) + " and " + convertFechaSQL(ultimoDia, mes, anio) + " \n" + " AND F.[Status] <> '11' \n" + " AND FD.[ID Vendedores] = " + vendedorId + ") x"; }
From source file:com.jjlharrison.jollyday.HolidayManager.java
License:Apache License
/** * Show if the requested date is a holiday. * * @param c//from w ww .j av a2s .c o m * The potential holiday. * @param args * Hierarchy to request the holidays for. i.e. args = {'ny'} -> * New York holidays * @return is a holiday in the state/region */ public boolean isHoliday(final LocalDate c, final String... args) { final StringBuilder keyBuilder = new StringBuilder(); keyBuilder.append(c.getYear()); for (String arg : args) { keyBuilder.append("_"); keyBuilder.append(arg); } Set<Holiday> holidays = holidayCache.get(new Cache.ValueHandler<Set<Holiday>>() { @Override public String getKey() { return keyBuilder.toString(); } @Override public Set<Holiday> createValue() { return getHolidays(c.getYear(), args); } }); return calendarUtil.contains(holidays, c); }