List of usage examples for org.joda.time DateTime getYear
public int getYear()
From source file:com.mpower.daktar.android.widgets.DateTimeWidget.java
License:Apache License
private void setAnswer() { if (mPrompt.getAnswerValue() != null) { final DateTime ldt = new DateTime( ((Date) ((DateTimeData) mPrompt.getAnswerValue()).getValue()).getTime()); mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener); mTimePicker.setCurrentHour(ldt.getHourOfDay()); mTimePicker.setCurrentMinute(ldt.getMinuteOfHour()); } else {/*from w w w . ja v a 2 s. c o m*/ // create time widget with current time as of right now clearAnswer(); } }
From source file:com.mpower.daktar.android.widgets.DateTimeWidget.java
License:Apache License
/** * Resets date to today./*from ww w. j av a 2s . co m*/ */ @Override public void clearAnswer() { final DateTime ldt = new DateTime(); mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener); mTimePicker.setCurrentHour(ldt.getHourOfDay()); mTimePicker.setCurrentMinute(ldt.getMinuteOfHour()); }
From source file:com.mpower.daktar.android.widgets.DateWidget.java
License:Apache License
private void setAnswer() { if (mPrompt.getAnswerValue() != null) { final DateTime ldt = new DateTime(((Date) ((DateData) mPrompt.getAnswerValue()).getValue()).getTime()); mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener); } else {/* ww w .j a va 2 s. c o m*/ // create date widget with current time as of right now clearAnswer(); } }
From source file:com.mpower.daktar.android.widgets.DateWidget.java
License:Apache License
/** * Resets date to today.// w ww .j av a 2 s.c om */ @Override public void clearAnswer() { final DateTime ldt = new DateTime(); mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener); }
From source file:com.mvcoding.financius.feature.DateDialogFragment.java
License:Open Source License
public static Observable<DateDialogResult> show(@NonNull FragmentManager fragmentManager, int requestCode, @NonNull RxBus rxBus, long timestamp) { final DateTime date = new DateTime(timestamp); return show(fragmentManager, requestCode, rxBus, date.getYear(), date.getMonthOfYear(), date.getDayOfMonth());//from w w w.jav a 2 s. c o m }
From source file:com.mvcoding.financius.feature.transaction.TransactionActivity.java
License:Open Source License
@NonNull @Override//from w ww .j a v a 2 s.c om public Observable<Long> onDateChanged() { final Observable<Long> dateObservable = rxBus.observe(DateDialogFragment.DateDialogResult.class) .mergeWith(RxView.clicks(dateButton).flatMap(o -> DateDialogFragment .show(getSupportFragmentManager(), REQUEST_DATE, rxBus, transaction.getDate()))) .map(dateDialogResult -> { final DateTime dateTime = new DateTime(transaction.getDate()); return new DateTime(dateDialogResult.getYear(), dateDialogResult.getMonthOfYear(), dateDialogResult.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour()) .getMillis(); }); final Observable<Long> timeObservable = rxBus.observe(TimeDialogFragment.TimeDialogResult.class) .mergeWith(RxView.clicks(timeButton).flatMap(o -> TimeDialogFragment .show(getSupportFragmentManager(), REQUEST_TIME, rxBus, transaction.getDate()))) .map(timeDialogResult -> { final DateTime dateTime = new DateTime(transaction.getDate()); return new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), timeDialogResult.getHourOfDay(), timeDialogResult.getMinuteOfHour()).getMillis(); }); return Observable.merge(dateObservable, timeObservable); }
From source file:com.mycompany.login.mb.DateBean.java
public static void main(String[] args) { Date date = new Date(); DateTime dateTime = new DateTime(date); DateTime dateTeste = new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour()); // System.out.println("ANO: " + dateTime.getYear()); // System.out.println("MES: " + dateTime.getMonthOfYear()); // System.out.println("DIA: " + dateTime.getDayOfMonth()); // System.out.println("HORA: " + dateTime.getHourOfDay()); // System.out.println("MINUTO: " + dateTime.getMinuteOfHour()); // System.out.println("Data Formatada:" + dateTime.getYear() + "/" + dateTime.getMonthOfYear() + "/" + dateTime.getDayOfMonth()); //System.out.println(dateTeste.toString("YYYY-MM-dd HH:mm")); LocalDate local = new LocalDate(date); System.out.println("Local Date: " + local); }
From source file:com.mycompany.vacationplanner.repository.CalendarPeriodRepositoryImpl.java
private void createPeriod(DateTime currentDate) { Date start = new GregorianCalendar(currentDate.getYear(), 8, 2).getTime(); Date end = new GregorianCalendar(currentDate.getYear() + 1, 8, 1).getTime(); save(new CalendarPeriod(Integer.toString(currentDate.getYear()), start, end)); }
From source file:com.netflix.ice.basic.BasicDataManager.java
License:Apache License
private File getFile(DateTime monthDate) { File file = new File(config.localDir, this.dbName); if (consolidateType == ConsolidateType.hourly) file = new File(config.localDir, this.dbName + "_" + AwsUtils.monthDateFormat.print(monthDate)); else if (consolidateType == ConsolidateType.daily) file = new File(config.localDir, this.dbName + "_" + monthDate.getYear()); return file;//from ww w .ja v a 2s . co m }
From source file:com.netflix.ice.processor.BillingFileProcessor.java
License:Apache License
private void archiveSummary(Map<Product, ReadWriteData> dataMap, String prefix) throws Exception { DateTime monthDateTime = new DateTime(startMilli, DateTimeZone.UTC); for (Product product : dataMap.keySet()) { String prodName = product == null ? "all" : product.name; ReadWriteData data = dataMap.get(product); Collection<TagGroup> tagGroups = data.getTagGroups(); // init daily, weekly and monthly List<Map<TagGroup, Double>> daily = Lists.newArrayList(); List<Map<TagGroup, Double>> weekly = Lists.newArrayList(); List<Map<TagGroup, Double>> monthly = Lists.newArrayList(); // get last month data ReadWriteData lastMonthData = new DataWriter(prefix + "hourly_" + prodName + "_" + AwsUtils.monthDateFormat.print(monthDateTime.minusMonths(1)), true).getData(); // aggregate to daily, weekly and monthly int dayOfWeek = monthDateTime.getDayOfWeek(); int daysFromLastMonth = dayOfWeek - 1; int lastMonthNumHours = monthDateTime.minusMonths(1).dayOfMonth().getMaximumValue() * 24; for (int hour = 0 - daysFromLastMonth * 24; hour < data.getNum(); hour++) { if (hour < 0) { // handle data from last month, add to weekly Map<TagGroup, Double> prevData = lastMonthData.getData(lastMonthNumHours + hour); for (TagGroup tagGroup : tagGroups) { Double v = prevData.get(tagGroup); if (v != null && v != 0) { addValue(weekly, 0, tagGroup, v); }/*w w w.j a v a2 s . c om*/ } } else { // this month, add to weekly, monthly and daily Map<TagGroup, Double> map = data.getData(hour); for (TagGroup tagGroup : tagGroups) { Double v = map.get(tagGroup); if (v != null && v != 0) { addValue(monthly, 0, tagGroup, v); addValue(daily, hour / 24, tagGroup, v); addValue(weekly, (hour + daysFromLastMonth * 24) / 24 / 7, tagGroup, v); } } } } // archive daily int year = monthDateTime.getYear(); DataWriter writer = new DataWriter(prefix + "daily_" + prodName + "_" + year, true); ReadWriteData dailyData = writer.getData(); dailyData.setData(daily, monthDateTime.getDayOfYear() - 1, false); writer.archive(); // archive monthly writer = new DataWriter(prefix + "monthly_" + prodName, true); ReadWriteData monthlyData = writer.getData(); monthlyData.setData(monthly, Months.monthsBetween(config.startDate, monthDateTime).getMonths(), false); writer.archive(); // archive weekly writer = new DataWriter(prefix + "weekly_" + prodName, true); ReadWriteData weeklyData = writer.getData(); DateTime weekStart = monthDateTime.withDayOfWeek(1); int index; if (!weekStart.isAfter(config.startDate)) index = 0; else index = Weeks.weeksBetween(config.startDate, weekStart).getWeeks() + (config.startDate.dayOfWeek() == weekStart.dayOfWeek() ? 0 : 1); weeklyData.setData(weekly, index, true); writer.archive(); } }