List of usage examples for org.joda.time DateTime getMonthOfYear
public int getMonthOfYear()
From source file:org.sindicato.beans.UtilBean.java
public String materializeDate(Date fecha) { String output = ""; if (fecha != null) { DateTime time = new DateTime(fecha); int day = time.getDayOfMonth(); int month = time.getMonthOfYear(); int year = time.getYear(); output += day;//from w w w . j a v a2s . c om switch (month) { case 1: output += " Enero"; break; case 2: output += " Febrero"; break; case 3: output += " Marzo"; break; case 4: output += " Abril"; break; case 5: output += " Mayo"; break; case 6: output += " Junio"; break; case 7: output += " Julio"; break; case 8: output += " Agosto"; break; case 9: output += " Septiembre"; break; case 10: output += " Octubre"; break; case 11: output += " Noviembre"; break; case 12: output += " Diciembre"; break; } output += ", " + year; } return output; }
From source file:org.sindicato.beans.UtilBean.java
public String fullSimpleArgDate(Date fecha) { String output = ""; if (fecha != null) { DateTime time = new DateTime(fecha); int day = time.getDayOfMonth(); int month = time.getMonthOfYear(); int year = time.getYear(); output = day + "-" + month + "-" + year; }//w w w. j a v a2 s . co m return output; }
From source file:org.sindicato.beans.UtilBean.java
public String fullSimpleMonthArgDate(Date fecha) { String output = ""; if (fecha != null) { DateTime time = new DateTime(fecha); output = String.valueOf(time.getDayOfMonth()) + "-"; switch (time.getMonthOfYear()) { case 1://from ww w .ja va2 s . c om output += "ENE"; break; case 2: output += "FEB"; break; case 3: output += "MAR"; break; case 4: output += "ABR"; break; case 5: output += "MAY"; break; case 6: output += "JUN"; break; case 7: output += "JUL"; break; case 8: output += "AGO"; break; case 9: output += "SEP"; break; case 10: output += "JUL"; break; case 11: output += "NOV"; break; case 12: output += "DIC"; break; } if (!output.equals("")) { output += "-" + time.getYear(); } } return output; }
From source file:org.sindicato.beans.UtilBean.java
public String monthByNumber(Date fecha) { String output = ""; if (fecha != null) { DateTime time = new DateTime(fecha); output = monthByNumber(time.getMonthOfYear()); }//from w w w . j a v a 2 s .co m return output; }
From source file:org.sindicato.converters.DateMaterializeConverter.java
@Override public String getAsString(FacesContext fc, UIComponent uic, Object o) { String result = ""; if (o != null) { DateTime time = new DateTime((Date) o); int day = time.getDayOfMonth(); int month = time.getMonthOfYear(); int year = time.getYear(); result += day;//w w w . j a v a 2 s .c om switch (month) { case 1: result += " Enero"; break; case 2: result += " Febrero"; break; case 3: result += " Marzo"; break; case 4: result += " Abril"; break; case 5: result += " Mayo"; break; case 6: result += " Junio"; break; case 7: result += " Julio"; break; case 8: result += " Agosto"; break; case 9: result += " Septiembre"; break; case 10: result += " Octubre"; break; case 11: result += " Noviembre"; break; case 12: result += " Diciembre"; break; } result += ", " + year; } else { throw new ConverterException("No se recibi ninguna fecha (Objeto)"); } return result; }
From source file:org.slc.sli.common.util.datetime.DateTimeUtil.java
License:Apache License
/** * Determines if the 1st date is before or equal to the 2nd date (comparing only year, month, day). * * @param date1 1st date object./* w w w. j a va 2 s . c o m*/ * @param date2 2nd date object. * @return true if date1 is before or equal to date2, false if date1 is after date2. */ public static boolean isLeftDateBeforeRightDate(DateTime date1, DateTime date2) { boolean less = false; if (date1.getYear() < date2.getYear()) { less = true; } else if (date1.getYear() == date2.getYear()) { if (date1.getMonthOfYear() < date2.getMonthOfYear()) { less = true; } else if (date1.getMonthOfYear() == date2.getMonthOfYear()) { if (date1.getDayOfMonth() <= date2.getDayOfMonth()) { less = true; } } } return less; }
From source file:org.sonar.plugins.scmstats.measures.ChangeLogHandler.java
License:Open Source License
public void generateMeasures() { for (ChangeLogInfo changeLogInfo : changeLogs) { if (!ignoredAuthors.contains(changeLogInfo.getAuthor())) { commitsPerUser = updateAuthorActivity(commitsPerUser, changeLogInfo); DateTime dt = new DateTime(changeLogInfo.getCommitDate()); commitsPerClockHour = MapUtils.updateMap(commitsPerClockHour, String.format("%2d", dt.getHourOfDay()).replace(' ', '0')); commitsPerWeekDay = MapUtils.updateMap(commitsPerWeekDay, dt.dayOfWeek().getAsString()); commitsPerMonth = MapUtils.updateMap(commitsPerMonth, String.format("%2d", dt.getMonthOfYear()).replace(' ', '0')); }/* ww w . j a v a2 s. co m*/ } }
From source file:org.sonar.plugins.scmstats.measures.CommitsPerMonthMeasure.java
License:Open Source License
@Override protected void init() { for (int i = 1; i <= 12; i++) { DateTime dt = new DateTime(2012, i, 1, 0, 0); getDataMap().put(String.format("%2d", dt.getMonthOfYear()).replace(' ', '0'), 0); }/*from w w w . j a va 2 s.c om*/ }
From source file:org.springframework.analytics.metrics.memory.InMemoryAggregateCounter.java
License:Apache License
public AggregateCounter getCounts(Interval interval, AggregateCounterResolution resolution) { DateTime start = interval.getStart(); DateTime end = interval.getEnd();/*from ww w . j a v a 2 s . co m*/ Chronology c = interval.getChronology(); long[] counts; if (resolution == AggregateCounterResolution.minute) { List<long[]> days = accumulateDayCounts(minuteCountsByDay, start, end, 60 * 24); counts = MetricUtils.concatArrays(days, interval.getStart().getMinuteOfDay(), interval.toPeriod().toStandardMinutes().getMinutes() + 1); } else if (resolution == AggregateCounterResolution.hour) { List<long[]> days = accumulateDayCounts(hourCountsByDay, start, end, 24); counts = MetricUtils.concatArrays(days, interval.getStart().getHourOfDay(), interval.toPeriod().toStandardHours().getHours() + 1); } else if (resolution == AggregateCounterResolution.day) { DateTime startDay = new DateTime(c.dayOfYear().roundFloor(start.getMillis())); DateTime endDay = new DateTime(c.dayOfYear().roundFloor(end.plusDays(1).getMillis())); int nDays = Days.daysBetween(startDay, endDay).getDays(); DateTime cursor = new DateTime(c.year().roundFloor(interval.getStartMillis())); List<long[]> yearDays = new ArrayList<long[]>(); DateTime endYear = new DateTime(c.year().roundCeiling(end.getMillis())); while (cursor.isBefore(endYear)) { long[] dayCounts = dayCountsByYear.get(cursor.getYear()); if (dayCounts == null) { // Querying where we have no data dayCounts = new long[daysInYear(cursor.getYear())]; } yearDays.add(dayCounts); cursor = cursor.plusYears(1); } counts = MetricUtils.concatArrays(yearDays, startDay.getDayOfYear() - 1, nDays); } else if (resolution == AggregateCounterResolution.month) { DateTime startMonth = new DateTime(c.monthOfYear().roundFloor(interval.getStartMillis())); DateTime endMonth = new DateTime(c.monthOfYear().roundFloor(end.plusMonths(1).getMillis())); int nMonths = Months.monthsBetween(startMonth, endMonth).getMonths(); DateTime cursor = new DateTime(c.year().roundFloor(interval.getStartMillis())); List<long[]> yearMonths = new ArrayList<long[]>(); DateTime endYear = new DateTime(c.year().roundCeiling(end.getMillis())); while (cursor.isBefore(endYear)) { long[] monthCounts = monthCountsByYear.get(cursor.getYear()); if (monthCounts == null) { monthCounts = new long[12]; } yearMonths.add(monthCounts); cursor = cursor.plusYears(1); } counts = MetricUtils.concatArrays(yearMonths, startMonth.getMonthOfYear() - 1, nMonths); } else if (resolution == AggregateCounterResolution.year) { DateTime startYear = new DateTime(interval.getStart().getYear(), 1, 1, 0, 0); DateTime endYear = new DateTime(end.getYear() + 1, 1, 1, 0, 0); int nYears = Years.yearsBetween(startYear, endYear).getYears(); counts = new long[nYears]; for (int i = 0; i < nYears; i++) { long[] monthCounts = monthCountsByYear.get(startYear.plusYears(i).getYear()); counts[i] = MetricUtils.sum(monthCounts); } } else { throw new IllegalStateException("Shouldn't happen. Unhandled resolution: " + resolution); } return new AggregateCounter(this.name, interval, counts, resolution); }