List of usage examples for org.joda.time DateTime now
public static DateTime now()
ISOChronology
in the default time zone. From source file:com.aionemu.gameserver.services.LoginEventService.java
License:Open Source License
private static Timestamp countNextRepeatTime() { DateTime now = DateTime.now(); DateTime repeatDate = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 9, 0, 0); if (now.isAfter(repeatDate)) { repeatDate = repeatDate.plusHours(24); }/*w w w . ja v a2s . c o m*/ return new Timestamp(repeatDate.getMillis()); }
From source file:com.aionemu.gameserver.services.QuestService.java
License:Open Source License
private static Timestamp countNextRepeatTime(Player player, QuestTemplate template) { DateTime now = DateTime.now(); DateTime repeatDate = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 9, 0, 0); if (template.isDaily()) { if (now.isAfter(repeatDate)) { repeatDate = repeatDate.plusHours(24); }// ww w. ja va 2 s . com PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1400855, "9")); } else { int daysToAdd = 7; int startDay = 7; for (QuestRepeatCycle weekDay : template.getRepeatCycle()) { int diff = weekDay.getDay() - repeatDate.getDayOfWeek(); if (diff > 0 && diff < daysToAdd) { daysToAdd = diff; } if (startDay > weekDay.getDay()) { startDay = weekDay.getDay(); } } if (startDay == daysToAdd) { daysToAdd = 7; } else if (daysToAdd == 7 && startDay < 7) { daysToAdd = 7 - repeatDate.getDayOfWeek() + startDay; } repeatDate = repeatDate.plusDays(daysToAdd); PacketSendUtility.sendPacket(player, new SM_SYSTEM_MESSAGE(1400857, new DescriptionId(1800667), "9")); } return new Timestamp(repeatDate.getMillis()); }
From source file:com.aliakseipilko.flightdutytracker.presenter.impl.FlightPresenter.java
License:Open Source License
public void initAdapaterData() { adapter = new FlightAdapter(view, null); view.setAdapter(adapter);//ww w. ja v a2 s. com getMultipleFlightsByDateRange(DateTime.now().minusDays(7).toDate(), new Date()); }
From source file:com.aliakseipilko.flightdutytracker.presenter.impl.HourPresenter.java
License:Open Source License
@Override public void getDutyHoursInPastDays(int days) { DateTime dateTime = DateTime.now(); Date startDate = dateTime.minusDays(days).toDate(); repository.getMultipleFlightsByDateRange(startDate, new Date(), Sort.DESCENDING, getMultipleFlightsDutyHoursCallback); }
From source file:com.aliakseipilko.flightdutytracker.presenter.impl.HourPresenter.java
License:Open Source License
@Override public void getFlightHoursInPastDays(int days) { DateTime dateTime = DateTime.now(); Date startDate = dateTime.minusDays(days).toDate(); repository.getMultipleFlightsByDateRange(startDate, new Date(), Sort.DESCENDING, getMultipleFlightsFlightHoursCallback); }
From source file:com.aliakseipilko.flightdutytracker.view.adapter.DayBarChartAdapter.java
License:Open Source License
private void processDutyHours() { List<BarEntry> barDutyEntries = new ArrayList<>(); float xValueCount = 0f; int maxDaysInMonth = 0; long startDay = new DateTime(flights.minDate("startDutyTime")).getDayOfMonth(); long currentYear = 0; long currentMonth = 0; long currentDay = 0; boolean isMonthWrapping = false; for (Flight flight : flights) { DateTime startDateTime = new DateTime(flight.getStartDutyTime()); DateTime endDateTime = new DateTime(flight.getEndDutyTime()); float decHoursDiff = (Seconds.secondsBetween(startDateTime, endDateTime).getSeconds() / 60f) / 60f; //Dont display stats for today as they will be malformed if (startDateTime.getDayOfYear() == DateTime.now().getDayOfYear() && startDateTime.getYear() == DateTime.now().getYear()) { continue; }//w w w . j av a 2 s . c o m if (currentYear == 0 && currentMonth == 0 && currentDay == 0) { currentYear = startDateTime.getYear(); currentMonth = startDateTime.getMonthOfYear(); currentDay = startDateTime.getDayOfMonth(); maxDaysInMonth = determineDaysInMonth((int) currentMonth, (int) currentYear); //Add new entry using day of month as x value BarEntry newEntry = new BarEntry(xValueCount, decHoursDiff); barDutyEntries.add(newEntry); xValueCount++; } else { //Check if month is wrapping if (currentDay + 1 >= maxDaysInMonth) { isMonthWrapping = true; } else { //Check if days are adjacent //Add skipped days onto xValueCount to display blank spaces in graph if (currentDay + 1 != startDateTime.getDayOfMonth()) { xValueCount += (startDateTime.getDayOfMonth() - currentDay) - 1; } } //Check if the date is the same as the previous flight // All flights are provided in an ordered list by the repo if (currentDay == startDateTime.getDayOfMonth() && currentMonth == startDateTime.getMonthOfYear() && currentYear == startDateTime.getYear()) { //Get last entry in list BarEntry lastEntry = barDutyEntries.get(barDutyEntries.size() - 1); //Add the additional hours in that day on, X value (the date) does not change lastEntry = new BarEntry(lastEntry.getX(), lastEntry.getY() + decHoursDiff); //Remove the last entry and add the modified entry instead of it barDutyEntries.remove(barDutyEntries.size() - 1); barDutyEntries.add(lastEntry); } else { //Check if days of month wrap around if (startDateTime.getMonthOfYear() != currentMonth) { isMonthWrapping = true; } //New day //Update these for the next iteration currentYear = startDateTime.getYear(); currentMonth = startDateTime.getMonthOfYear(); currentDay = startDateTime.getDayOfMonth(); //Add new entry using day of month as x value BarEntry newEntry = new BarEntry(xValueCount, decHoursDiff); barDutyEntries.add(newEntry); xValueCount++; } } } IAxisValueFormatter xAxisValueFormatter = new DayAxisValueFormatter((int) (startDay - 1), maxDaysInMonth); IAxisValueFormatter yAxisValueFormatter = new DefaultAxisValueFormatter(2); BarDataSet dataSet = new BarDataSet(barDutyEntries, "Duty Hours"); dataSet.setValueTextSize(16f); BarData barDutyData = new BarData(dataSet); barDutyData.setBarWidth(0.9f); barDutyData.setHighlightEnabled(false); view.setupDutyBarChart(barDutyData, xAxisValueFormatter, yAxisValueFormatter); }
From source file:com.aliakseipilko.flightdutytracker.view.adapter.DayBarChartAdapter.java
License:Open Source License
private void processFlightHours() { List<BarEntry> barFlightEntries = new ArrayList<>(); float xValueCount = 0f; int maxDaysInMonth = 0; long startDay = new DateTime(flights.minDate("startFlightTime")).getDayOfMonth(); long currentYear = 0; long currentMonth = 0; long currentDay = 0; boolean isMonthWrapping = false; for (Flight flight : flights) { DateTime startDateTime = new DateTime(flight.getStartFlightTime()); DateTime endDateTime = new DateTime(flight.getEndFlightTime()); float decHoursDiff = (Seconds.secondsBetween(startDateTime, endDateTime).getSeconds() / 60f) / 60f; //Dont display stats for today as they will be malformed if (startDateTime.getDayOfYear() == DateTime.now().getDayOfYear() && startDateTime.getYear() == DateTime.now().getYear()) { continue; }//from w ww . j av a 2 s. co m if (currentYear == 0 && currentMonth == 0 && currentDay == 0) { currentYear = startDateTime.getYear(); currentMonth = startDateTime.getMonthOfYear(); currentDay = startDateTime.getDayOfMonth(); maxDaysInMonth = determineDaysInMonth((int) currentMonth, (int) currentYear); //Add new entry using day of month as x value BarEntry newEntry = new BarEntry(xValueCount, decHoursDiff); barFlightEntries.add(newEntry); xValueCount++; } else { //Check if month is wrapping if (currentDay + 1 >= maxDaysInMonth) { isMonthWrapping = true; } else { //Check if days are adjacent //Add skipped days onto xValueCount to display blank spaces in graph if (currentDay + 1 != startDateTime.getDayOfMonth()) { xValueCount = xValueCount + (startDateTime.getDayOfMonth() - currentDay) - 1; } } //Check if the date is the same as the previous flight // All flights are provided in an ordered list by the repo if (currentDay == startDateTime.getDayOfMonth() && currentMonth == startDateTime.getMonthOfYear() && currentYear == startDateTime.getYear()) { //Get last entry in list BarEntry lastEntry = barFlightEntries.get(barFlightEntries.size() - 1); //Add the additional hours in that day on, X value (the date) does not change lastEntry = new BarEntry(lastEntry.getX(), lastEntry.getY() + decHoursDiff); //Remove the last entry and add the modified entry instead of it barFlightEntries.remove(barFlightEntries.size() - 1); barFlightEntries.add(lastEntry); } else { //Check if days of month wrap around if (startDateTime.getMonthOfYear() != currentMonth) { isMonthWrapping = true; } //New day //Update these for the next iteration currentYear = startDateTime.getYear(); currentMonth = startDateTime.getMonthOfYear(); currentDay = startDateTime.getDayOfMonth(); //Add new entry using day of month as x value BarEntry newEntry = new BarEntry(xValueCount, decHoursDiff); barFlightEntries.add(newEntry); xValueCount++; } } } IAxisValueFormatter xAxisValueFormatter = new DayAxisValueFormatter((int) (startDay - 1), maxDaysInMonth); IAxisValueFormatter yAxisValueFormatter = new DefaultAxisValueFormatter(2); BarDataSet dataSet = new BarDataSet(barFlightEntries, "Flight Hours"); dataSet.setValueTextSize(16f); BarData barFlightData = new BarData(dataSet); barFlightData.setBarWidth(0.9f); barFlightData.setHighlightEnabled(false); view.setupFlightBarChart(barFlightData, xAxisValueFormatter, yAxisValueFormatter); }
From source file:com.aliakseipilko.flightdutytracker.view.fragment.statsFragments.SevenDaysStatsFragment.java
License:Open Source License
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_seven_days_stats, container, false); unbinder = ButterKnife.bind(this, view); chartAdapter = new DayBarChartAdapter(this); presenter = new StatsPresenter(this, chartAdapter); presenter.subscribeAllCallbacks();//from w w w.ja v a 2 s.c om presenter.getMultipleFlightsByDateRange(DateTime.now().minusDays(7).toDate(), new Date()); return view; }
From source file:com.aliakseipilko.flightdutytracker.view.fragment.statsFragments.TwentyEightDaysStatsFragment.java
License:Open Source License
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_twenty_eight_days_stats, container, false); unbinder = ButterKnife.bind(this, view); chartAdapter = new DayBarChartAdapter(this); presenter = new StatsPresenter(this, chartAdapter); presenter.subscribeAllCallbacks();//w ww. java 2 s . c o m presenter.getMultipleFlightsByDateRange(DateTime.now().minusDays(28).toDate(), new Date()); return view; }
From source file:com.aliakseipilko.flightdutytracker.view.fragment.statsFragments.YearStatsFragment.java
License:Open Source License
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_year_stats, container, false); unbinder = ButterKnife.bind(this, view); chartAdapter = new MonthBarChartAdapter(this); presenter = new StatsPresenter(this, chartAdapter); presenter.subscribeAllCallbacks();//from w w w . j ava 2 s . c om presenter.getMultipleFlightsByDateRange(DateTime.now().minusYears(1).toDate(), new Date()); return view; }