List of usage examples for org.joda.time DateMidnight DateMidnight
public DateMidnight()
ISOChronology
in the default time zone. From source file:com.google.android.apps.paco.ExperimentScheduleActivity.java
License:Open Source License
private Long getHourOffsetFromPicker() { return new Long(new DateMidnight().toDateTime().withHourOfDay(timePicker.getCurrentHour()) .withMinuteOfHour(timePicker.getCurrentMinute()).getMillisOfDay()); }
From source file:com.google.android.apps.paco.ExperimentScheduleActivity.java
License:Open Source License
private String getTextFromPicker(int esmOffset) { return new DateMidnight().toDateTime().withMillisOfDay(esmOffset).toString(TIME_FORMAT_STRING); }
From source file:com.google.android.apps.paco.SignalSchedule.java
License:Open Source License
public String getHourOffsetAsTimeString(Long esmEndHour2) { DateTime endHour = new DateMidnight().toDateTime().plus(esmEndHour2); String endHourString = endHour.getHourOfDay() + ":" + pad(endHour.getMinuteOfHour()); return endHourString; }
From source file:com.google.sampling.experiential.model.SignalSchedule.java
License:Open Source License
public String getHourOffsetAsTimeString(Long time) { DateTime endHour = new DateMidnight().toDateTime().plus(time); String endHourString = endHour.getHourOfDay() + ":" + pad(endHour.getMinuteOfHour()); return endHourString; }
From source file:com.google.sampling.experiential.model.SignalSchedule.java
License:Open Source License
public String getHourOffsetAsTimeString(SignalTime time) { DateTime endHour = new DateMidnight().toDateTime().plus(time.getFixedTimeMillisFromMidnight()); String endHourString = endHour.getHourOfDay() + ":" + pad(endHour.getMinuteOfHour()); return endHourString; }
From source file:com.kopysoft.chronos.views.ClockFragments.Today.DatePairView.java
License:Open Source License
public DatePairView(SherlockActivity prnt, List<Punch> punches, DateTime date) { super(prnt.getApplicationContext()); gDate = date;//www. j av a 2s. co m parent = prnt; if (enableLog) { Log.d(TAG, "Entry 2"); for (Punch p : punches) { Log.d(TAG, "init punch: " + p); } Log.d(TAG, "init date: " + date); } Chronos chrono = new Chronos(parent); thisJob = chrono.getAllJobs().get(0); if (enableLog) Log.d(TAG, "Entry 2 Pay: " + thisJob.getPayRate()); chrono.close(); adapter = new TodayAdapterPair(parent, punches, thisJob); if (adapter.getTime(true).getMillis() < 0 && date.toDateMidnight().isEqual(new DateMidnight())) { mHandler.postDelayed(mUpdateTimeTask, 100); } else { mHandler.removeCallbacks(mUpdateTimeTask); } createUI(adapter, thisJob); }
From source file:com.kopysoft.chronos.views.ClockFragments.Today.DatePairView.java
License:Open Source License
private void createUI(TodayAdapterPair adpter, Job thisJob) { //if(enableLog) Log.d(TAG, "Position: " + position); setOrientation(LinearLayout.VERTICAL); //retView.setOnItemLongClickListener(LongClickListener); header = View.inflate(getContext(), R.layout.today_view, null); DateTimeFormatter fmt = DateTimeFormat.forPattern("E, MMM d, yyyy"); ((TextView) header.findViewById(R.id.date)).setText(fmt.print(gDate)); if (!showPay()) { header.findViewById(R.id.moneyViewText).setVisibility(View.GONE); header.findViewById(R.id.moneyViewTotal).setVisibility(View.GONE); }//from w w w. j a v a 2 s . co m ListView retView = (ListView) header.findViewById(R.id.listView); retView.setOnItemClickListener(listener); TextView tx = (TextView) header.findViewById(R.id.timeViewTotal); Duration dur = adapter.getTime(true); if (dur.getMillis() < 0 && gDate.toDateMidnight().isEqual(new DateMidnight())) { dur = dur.plus(DateTime.now().getMillis()); } int seconds = (int) dur.getStandardSeconds(); int minutes = (seconds / 60) % 60; int hours = (seconds / 60 / 60); String output = String.format("%d:%02d:%02d", hours, minutes, seconds % 60); if (dur.getMillis() >= 0) tx.setText(output); else tx.setText("--:--:--"); if (enableLog) Log.d(TAG, "job: " + thisJob); if (enableLog) Log.d(TAG, "seconds: " + seconds); if (enableLog) Log.d(TAG, "dur: " + dur.toString()); if (enableLog) Log.d(TAG, "pay rate: " + thisJob.getPayRate()); double money = adapter.getPayableTime(gDate.toDateMidnight().isEqual(new DateMidnight())); Currency moneyCurrency = Currency.getInstance(Locale.getDefault()); output = String.format("%s %.2f", moneyCurrency.getSymbol(), money); tx = (TextView) header.findViewById(R.id.moneyViewTotal); tx.setText(output); if (enableLog) Log.d(TAG, "pay amount: " + output); //header to the row addView(header); retView.setAdapter(adpter); retView.setSelection(0); //show button if (!gDate.toDateMidnight().isEqual(new DateMidnight())) { header.findViewById(R.id.clockInAndOutButton).setVisibility(View.GONE); } else { (header.findViewById(R.id.clockInAndOutButton)).setOnClickListener(buttonListener); if (dur.getMillis() < 0) { ((Button) header.findViewById(R.id.clockInAndOutButton)).setText("Clock Out"); } else { ((Button) header.findViewById(R.id.clockInAndOutButton)).setText("Clock In"); } } }
From source file:com.kopysoft.chronos.views.ClockFragments.Today.DatePairView.java
License:Open Source License
private void updateTime() { TextView tx = (TextView) header.findViewById(R.id.timeViewTotal); Duration dur = adapter.getTime(true); if (dur.getMillis() < 0 && gDate.toDateMidnight().isEqual(new DateMidnight())) { dur = dur.plus(DateTime.now().getMillis()); }/* w ww . j av a 2s . c om*/ int seconds = (int) dur.getStandardSeconds(); int minutes = (seconds / 60) % 60; int hours = (seconds / 60 / 60); String output = String.format("%d:%02d:%02d", hours, minutes, seconds % 60); tx.setText(output); double money = adapter.getPayableTime(true); Currency moneyCurrency = Currency.getInstance(Locale.getDefault()); output = String.format("%s %.2f", moneyCurrency.getSymbol(), money); tx = (TextView) header.findViewById(R.id.moneyViewTotal); tx.setText(output); if (enableLog) Log.d(TAG, "pay amount: " + output); }
From source file:com.latlab.common.model.PeriodUtils.java
/** * Obtains a Map of {@link YearQuarterDate} for all the quarters of the * specified year. If <code>year</code> value is 0 or less, it is assumed * that the year is the current year./* w w w.j ava2 s . co m*/ * * @param year * @return */ public static Map<Period, DateRange> getQuarterDates(int year) { Map<Period, DateRange> quarterMap = new HashMap<>(); DateMidnight refDate = new DateMidnight(); if (year > 0) { refDate = refDate.withYear(year); } refDate = refDate.withMonthOfYear(1).withDayOfMonth(1); Date startDate1 = refDate.toDate(); refDate = refDate.plusMonths(2); refDate = refDate.withDayOfMonth(refDate.dayOfMonth().getMaximumValue()); Date endDate1 = new DateTime(refDate.toDateTime()).withHourOfDay(23).withMinuteOfHour(59) .withSecondOfMinute(59).toDate(); DateRange quarterDate = new DateRange(Period.FIRST_QUARTER, year, startDate1, endDate1); quarterMap.put(quarterDate.getPeriod(), quarterDate); refDate = refDate.withMonthOfYear(4).withDayOfMonth(1); Date starteDate2 = refDate.toDate(); refDate = refDate.plusMonths(2); refDate = refDate.withDayOfMonth(refDate.dayOfMonth().getMaximumValue()); Date endDate2 = new DateTime(refDate.toDateTime()).withHourOfDay(23).withMinuteOfHour(59) .withSecondOfMinute(59).toDate(); DateRange quarterDate2 = new DateRange(Period.SECOND_QUARTER, year, starteDate2, endDate2); quarterMap.put(quarterDate2.getPeriod(), quarterDate2); refDate = refDate.withMonthOfYear(7).withDayOfMonth(1); Date starteDate3 = refDate.toDate(); refDate = refDate.plusMonths(2); refDate = refDate.withDayOfMonth(refDate.dayOfMonth().getMaximumValue()); Date endDate3 = new DateTime(refDate.toDateTime()).withHourOfDay(23).withMinuteOfHour(59) .withSecondOfMinute(59).toDate(); DateRange quarterDate3 = new DateRange(Period.THIRD_QUARTER, year, starteDate3, endDate3); quarterMap.put(quarterDate3.getPeriod(), quarterDate3); refDate = refDate.withMonthOfYear(10).withDayOfMonth(1); Date starteDate4 = refDate.toDate(); refDate = refDate.plusMonths(2); refDate = refDate.withDayOfMonth(refDate.dayOfMonth().getMaximumValue()); Date endDate4 = new DateTime(refDate.toDateTime()).withHourOfDay(23).withMinuteOfHour(59) .withSecondOfMinute(59).toDate(); DateRange quarterDate4 = new DateRange(Period.LAST_QUARTER, refDate.getYear(), starteDate4, endDate4); quarterMap.put(quarterDate4.getPeriod(), quarterDate4); return quarterMap; }
From source file:com.liteoc.logic.expressionTree.OpenClinicaVariableNode.java
License:LGPL
private String calculateVariable() { if (number.equals("_CURRENT_DATE")) { DateMidnight dm = new DateMidnight(); DateTimeFormatter fmt = ISODateTimeFormat.date(); return fmt.print(dm); }// ww w .ja v a 2 s . c o m return null; }