List of usage examples for org.joda.time LocalDate getMonthOfYear
public int getMonthOfYear()
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 a va 2 s .com }
From source file:com.helger.datetime.xml.PDTXMLConverter.java
License:Apache License
/** * Get the passed object as {@link XMLGregorianCalendar} date (without a * time).//from w w w. ja va 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.jseppa.mql4java.util.DateUtil.java
License:Apache License
public static DateTime addDateAndTime(LocalDate date, LocalTime time) { return new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), time.getHourOfDay(), time.getMinuteOfHour(), time.getSecondOfMinute(), DATE_TZ); }
From source file:com.mbc.jfin.daycount.impl.calculator.AFBActualActualDaycountCalculator.java
License:Open Source License
public double calculateDaycountFraction(SchedulePeriod period) { int daysBetween = DateUtils.daysBetween(period.getStart(), period.getEnd()); if (daysBetween == 0) return 0; LocalDate newD2 = period.getEnd(); LocalDate temp = period.getEnd(); double sum = 0.0; while (temp.isAfter(period.getStart())) { temp = newD2;/*from w w w . j a va 2s . c o m*/ temp = temp.minus(Years.ONE); if (temp.getDayOfMonth() == 28 && temp.getMonthOfYear() == 2 && DateUtils.isLeapYear(temp)) { temp = temp.plus(Days.ONE); } if (temp.isAfter(period.getStart()) || temp.equals(period.getStart())) { sum += 1.0; newD2 = temp; } } double den = 365.0; if (DateUtils.isLeapYear(newD2)) { temp = newD2; temp = new LocalDate(temp.getYear(), 2, 29); if (newD2.isAfter(temp) && (period.getStart().isBefore(temp) || period.getStart().equals(temp))) den += 1.0; } else if (DateUtils.isLeapYear(period.getStart())) { temp = new LocalDate(period.getStart().getYear(), 2, 29); if (newD2.isAfter(temp) && (period.getStart().isBefore(temp) || period.getStart().equals(temp))) den += 1.0; } return sum + DateUtils.daysBetween(period.getStart(), newD2) / den; }
From source file:com.mbc.jfin.holiday.impl.DefaultDateAdjustmentServiceImpl.java
License:Open Source License
private LocalDate monthEndReference(LocalDate calendar, HolidayCalendar holidayCalendar) { LocalDate d1 = new LocalDate(calendar.getYear(), calendar.getMonthOfYear(), DateUtils.getDaysInMonth(calendar)); return preceding(d1, holidayCalendar); }
From source file:com.mbc.jfin.holiday.impl.DefaultDateAdjustmentServiceImpl.java
License:Open Source License
public LocalDate modFollowing(LocalDate calendar, HolidayCalendar holidayCalendar) { LocalDate d1 = calendar; while (holidayCalendar.isHoliday(d1) || holidayCalendar.isWeekend(d1)) { d1 = d1.plus(Days.ONE);/* w w w . j a v a2s .c om*/ } if (d1.getMonthOfYear() != calendar.getMonthOfYear()) { return preceding(calendar, holidayCalendar); } return d1; }
From source file:com.mbc.jfin.holiday.impl.DefaultDateAdjustmentServiceImpl.java
License:Open Source License
public LocalDate modPreceding(LocalDate calendar, HolidayCalendar holidayCalendar) { LocalDate d1 = calendar; while (holidayCalendar.isHoliday(d1) || holidayCalendar.isWeekend(d1)) { d1 = d1.minus(Days.ONE);//from w ww. j a v a2 s .c om } if (d1.getMonthOfYear() != calendar.getMonthOfYear()) { return following(calendar, holidayCalendar); } return d1; }
From source file:com.mbc.jfin.util.DateUtils.java
License:Open Source License
public static int getDaysInMonth(LocalDate date) { switch (date.getMonthOfYear()) { case 2:// w ww . ja va 2 s . c om if (isLeapYear(date)) { return 29; } else { return 28; } case 1: case 3: case 5: case 7: case 8: case 10: case 12: return 31; default: return 30; } }
From source file:com.metinkale.prayerapp.HicriDate.java
License:Apache License
public HicriDate(LocalDate greg) { // int[] key = {d, m, y}; //int[] ret = mCache.get(key); //if (ret != null) return ret; int hfix = Prefs.getHijriFix(); if (hfix != 0) { greg = greg.plusDays(hfix);/*from w w w. ja v a2 s.c o m*/ } int d = greg.getDayOfMonth(); int m = greg.getMonthOfYear(); int y = greg.getYear(); int[] last = null; for (int[] date : mDates) { if (date[GY] < y) { last = date; } else if ((date[GY] == y) && (date[GM] < m)) { last = date; } else if ((date[GY] == y) && (date[GM] == m) && (date[GD] <= d)) { last = date; } else { break; } } if (last == null) { LocalDate date = greg.toDateTimeAtStartOfDay().withChronology(IslamicChronology.getInstance()) .toLocalDate(); Year = date.getYear(); Month = date.getMonthOfYear(); Day = date.getDayOfMonth(); } else { int[] h = { last[HD], last[HM], last[HY] }; h[0] += new LocalDate(y, m, d).getDayOfYear() - new LocalDate(last[GY], last[GM], last[GD]).getDayOfYear(); if ((h[0] >= 30) || (h[0] <= 0)) { LocalDate date = greg.toDateTimeAtStartOfDay().withChronology(IslamicChronology.getInstance()) .toLocalDate(); Year = date.getYear(); Month = date.getMonthOfYear(); Day = date.getDayOfMonth(); } else { Year = h[HY]; Month = h[HM]; Day = h[HD]; } } }