List of usage examples for org.joda.time LocalDate getYear
public int getYear()
From source file:at.jclehner.rxdroid.preferences.DatePreference.java
License:Open Source License
@TargetApi(11) @Override/*from w ww. ja va 2 s. c o m*/ protected View onCreateDialogView() { final LocalDate value = getValue(); final DatePicker picker = new DatePicker(getThemedContext()); if (Version.SDK_IS_HONEYCOMB_OR_NEWER) picker.setMinDate(mToday.toDate().getTime()); picker.init(value.getYear(), value.getMonthOfYear() - 1, value.getDayOfMonth(), this); return picker; }
From source file:at.jclehner.rxdroid.util.Util.java
License:Open Source License
@TargetApi(11) public static AlertDialog createDatePickerDialog(Context context, LocalDate date, final DatePickerDialog.OnDateSetListener listener) { final DatePicker picker = new DatePicker(context); picker.init(date.getYear(), date.getMonthOfYear() - 1, date.getDayOfMonth(), null); if (Version.SDK_IS_HONEYCOMB_OR_NEWER && !context.getResources().getBoolean(R.bool.is_tablet)) picker.setCalendarViewShown(false); final AlertDialog.Builder ab = new AlertDialog.Builder(context); ab.setView(picker);//from w w w . j a v a 2s .com ab.setNegativeButton(android.R.string.cancel, null); ab.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { listener.onDateSet(picker, picker.getYear(), picker.getMonth(), picker.getDayOfMonth()); } }); return ab.create(); }
From source file:br.com.moonjava.flight.util.VerifierString.java
License:Apache License
public static boolean isBirthDay(String word, String country) { boolean birthDay = false; LocalDate date = FormatDateTimeDesk.parseToLocalDate(word, country); boolean leapYear = new GregorianCalendar().isLeapYear(date.getYear()); LocalDate now = new LocalDate(); // US MM/DD/YYYY if (country.equals("US")) { // No pode conter 30 e 31 em fevereiro e nem ser maior que a data atual if (!word.startsWith("02/30") && !word.startsWith("02/31") && date.isBefore(now) || date.isEqual(now)) { // Se for bissexto deve considerar 02/29 if (word.startsWith("02/29") && leapYear || !word.startsWith("02/29")) { Pattern pattern = Pattern.compile("(0[1-9]|1[012])/(0[1-9]|[12][0-9]|3[01])/((19|20)\\d\\d)"); Matcher matcher = pattern.matcher(word); birthDay = matcher.find(); }//from w ww.j a va2 s . c o m } // BR DD/MM/YYYY } else { if (!word.startsWith("30/02") && !word.startsWith("31/02") && date.isBefore(now) || date.isEqual(now)) { // No pode conter 30 e 31 em fevereiro e nem ser maior que a data atual if (word.startsWith("29/02") && leapYear || !word.startsWith("29/02")) { // Se for bissexto deve considerar 29/02 Pattern pattern = Pattern.compile("(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/((19|20)\\d\\d)"); Matcher matcher = pattern.matcher(word); birthDay = matcher.find(); } } } return birthDay; }
From source file:br.edu.unirio.pm.service.ServicosVendas.java
public List<Integer> obterAnosDisponiveisParaConsulta() throws SQLException { List<Integer> anosDisponiveisParaConsulta = new ArrayList<>(); LocalDate dataInicial = vendasDAO.obterDataDaVendaMaisAntiga(); LocalDate dataFinal = vendasDAO.obterDataDaVendaMaisAtual(); for (int ano = dataInicial.getYear(); ano <= dataFinal.getYear(); ano++) { anosDisponiveisParaConsulta.add(ano); }/*from w ww. ja v a 2 s. c o m*/ return anosDisponiveisParaConsulta; }
From source file:cache.BreakerCache.java
Vector<ElectricalValue> get_data(Breaker breaker, LocalDate startDate, LocalDate endDate, BaseCache cache) throws NoActiveDbConnectionException, NoItemSelectedException { Vector<ElectricalValue> toreturn = new Vector<>(); LocalDate currdate = null; int cacheditems = 0; int totalitems = 0; currdate = new LocalDate(startDate); while (currdate.isBefore(endDate)) { YearCache wanted_year = null;/*ww w .java 2 s . c o m*/ for (YearCache yc : years) { if (yc.year == currdate.getYear()) { wanted_year = yc; break; } } if (wanted_year == null) { wanted_year = new YearCache(currdate.getYear()); years.add(wanted_year); } MonthCache wanted_month = wanted_year.months[currdate.getMonthOfYear() - 1]; DayCache wanted_day = wanted_month.days[currdate.getDayOfMonth() - 1]; if (wanted_day.data != null) { cacheditems++; } totalitems++; currdate = currdate.plusDays(1); } if (cacheditems / totalitems > 0.9) { currdate = new LocalDate(startDate); while (currdate.isBefore(endDate)) { YearCache wanted_year = null; for (YearCache yc : years) { if (yc.year == currdate.getYear()) { wanted_year = yc; break; } } if (wanted_year == null) { wanted_year = new YearCache(currdate.getYear()); years.add(wanted_year); } MonthCache wanted_month = wanted_year.months[currdate.getMonthOfYear() - 1]; DayCache wanted_day = wanted_month.days[currdate.getDayOfMonth() - 1]; cache.cache_day(wanted_day); if (wanted_day.data == null) { wanted_day.data = LoadDataFromDB.get_data(breaker, currdate, currdate.plusDays(1)); } toreturn.addAll(wanted_day.data); currdate = currdate.plusDays(1); } } else { toreturn = LoadDataFromDB.get_data(breaker, startDate, endDate); currdate = new LocalDate(startDate); YearCache wanted_year = null; for (YearCache yc : years) { if (yc.year == currdate.getYear()) { wanted_year = yc; break; } } if (wanted_year == null) { wanted_year = new YearCache(currdate.getYear()); years.add(wanted_year); } MonthCache wanted_month = wanted_year.months[currdate.getMonthOfYear() - 1]; DayCache wanted_day = wanted_month.days[currdate.getDayOfMonth() - 1]; currdate = currdate.plusDays(1); Vector<ElectricalValue> daydata = new Vector<>(); for (int i = 0; i < toreturn.size(); i++) { if (toreturn.get(i).datetime.toLocalDate().isBefore(currdate)) { daydata.add(toreturn.get(i)); } else { if (daydata.size() > 0) { wanted_day.data = daydata; cache.cache_day(wanted_day); daydata = new Vector<>(); } wanted_year = null; for (YearCache yc : years) { if (yc.year == currdate.getYear()) { wanted_year = yc; break; } } if (wanted_year == null) { wanted_year = new YearCache(currdate.getYear()); years.add(wanted_year); } wanted_month = wanted_year.months[currdate.getMonthOfYear() - 1]; wanted_day = wanted_month.days[currdate.getDayOfMonth() - 1]; currdate = currdate.plusDays(1); } } } return toreturn; }
From source file:cache.TransformerCache.java
Vector<ElectricalValue> get_data(Transformer transformer, LocalDate startDate, LocalDate endDate, BaseCache cache) throws NoActiveDbConnectionException, NoItemSelectedException { Vector<ElectricalValue> toreturn = new Vector<>(); LocalDate currdate = null; int cacheditems = 0; int totalitems = 0; currdate = new LocalDate(startDate); while (currdate.isBefore(endDate)) { YearCache wanted_year = null;/* www. jav a2s .c o m*/ for (YearCache yc : years) { if (yc.year == currdate.getYear()) { wanted_year = yc; break; } } if (wanted_year == null) { wanted_year = new YearCache(currdate.getYear()); years.add(wanted_year); } MonthCache wanted_month = wanted_year.months[currdate.getMonthOfYear() - 1]; DayCache wanted_day = wanted_month.days[currdate.getDayOfMonth() - 1]; if (wanted_day.data != null) { cacheditems++; } totalitems++; currdate = currdate.plusDays(1); } if (cacheditems / totalitems > 0.9) { currdate = new LocalDate(startDate); while (currdate.isBefore(endDate)) { YearCache wanted_year = null; for (YearCache yc : years) { if (yc.year == currdate.getYear()) { wanted_year = yc; break; } } if (wanted_year == null) { wanted_year = new YearCache(currdate.getYear()); years.add(wanted_year); } MonthCache wanted_month = wanted_year.months[currdate.getMonthOfYear() - 1]; DayCache wanted_day = wanted_month.days[currdate.getDayOfMonth() - 1]; cache.cache_day(wanted_day); if (wanted_day.data == null) { wanted_day.data = LoadDataFromDB.get_data(transformer, currdate, currdate.plusDays(1)); } toreturn.addAll(wanted_day.data); currdate = currdate.plusDays(1); } } else { toreturn = LoadDataFromDB.get_data(transformer, startDate, endDate); currdate = new LocalDate(startDate); YearCache wanted_year = null; for (YearCache yc : years) { if (yc.year == currdate.getYear()) { wanted_year = yc; break; } } if (wanted_year == null) { wanted_year = new YearCache(currdate.getYear()); years.add(wanted_year); } MonthCache wanted_month = wanted_year.months[currdate.getMonthOfYear() - 1]; DayCache wanted_day = wanted_month.days[currdate.getDayOfMonth() - 1]; currdate = currdate.plusDays(1); Vector<ElectricalValue> daydata = new Vector<>(); for (int i = 0; i < toreturn.size(); i++) { if (toreturn.get(i).datetime.toLocalDate().isBefore(currdate)) { daydata.add(toreturn.get(i)); } else { if (daydata.size() > 0) { wanted_day.data = daydata; cache.cache_day(wanted_day); daydata = new Vector<>(); } wanted_year = null; for (YearCache yc : years) { if (yc.year == currdate.getYear()) { wanted_year = yc; break; } } if (wanted_year == null) { wanted_year = new YearCache(currdate.getYear()); years.add(wanted_year); } wanted_month = wanted_year.months[currdate.getMonthOfYear() - 1]; wanted_day = wanted_month.days[currdate.getDayOfMonth() - 1]; currdate = currdate.plusDays(1); } } } return toreturn; }
From source file:cherry.foundation.bizcal.BizYearManagerImpl.java
License:Apache License
private Pair<Integer, Range<LocalDate>> bizYearByDate(LocalDate dt) { return bizYearByDate(dt.getYear(), dt); }
From source file:cherry.goods.util.JodaTimeUtil.java
License:Apache License
/** * @param ldt ???{@link LocalDate}/*from www . ja v a 2s. c om*/ * @return ?????{@link Calendar}(?)????????(?00:00:00.000) */ public static Calendar getCalendar(LocalDate ldt) { Calendar cal = Calendar.getInstance(); cal.set(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), 0, 0, 0); cal.set(MILLISECOND, 0); return cal; }
From source file:cherry.goods.util.LocalDateUtil.java
License:Apache License
/** * (??)?????(Y/M/1?)???//from w ww. j av a 2 s. co m * * @param dt ?? * @return (??)??? */ public static LocalDate normalizeYm(LocalDate dt) { if (dt == null) { return null; } return new LocalDate(dt.getYear(), dt.getMonthOfYear(), 1); }
From source file:Classes.HijriTime.java
License:Open Source License
public String getHijriTime() {////get final translated hijri date this.dayFormatter = new DecimalFormat("00"); this.yearFormatter = new DecimalFormat("0000"); Chronology iSOChronology = ISOChronology.getInstanceUTC();//get ISOChronology instance Chronology islamicChronology = IslamicChronology.getInstanceUTC();//get IslamicChronology instance LocalDate localDateISOChronology = new LocalDate(year, month, day, iSOChronology);//get local date LocalDate HijriDate = new LocalDate(localDateISOChronology.toDate(), islamicChronology);//get hijri date return hijriDaysNames[calendar.get(Calendar.DAY_OF_WEEK)] + " " + dayFormatter.format(HijriDate.getDayOfMonth()) + " " + hijriMonthsNames[HijriDate.getMonthOfYear()] + " " + yearFormatter.format(HijriDate.getYear()); }