List of usage examples for org.joda.time DateTime DateTime
public DateTime(Object instant)
From source file:com.aionemu.gameserver.services.HousingBidService.java
License:Open Source License
public boolean isRegisteringAllowed() { DateTime now = DateTime.now();// w ww.j a v a 2s.c o m DateTime registerEnd = new DateTime(registerDateExpr.getTimeAfter(now.toDate())); DateTime auctionEnd = new DateTime(((long) getRunTime() + timeProlonged * 60) * 1000); if (now.getDayOfWeek() == registerEnd.getDayOfWeek() && now.getHourOfDay() >= registerEnd.getHourOfDay() || (now.getDayOfWeek() == auctionEnd.getDayOfWeek() && now.getHourOfDay() <= auctionEnd.getHourOfDay())) { return false; } return true; }
From source file:com.aionemu.gameserver.services.HousingBidService.java
License:Open Source License
public AuctionResult completeHouseSell(PlayerCommonData winner, House obtainedHouse) { House winnerHouse = HousingService.getInstance().getPlayerStudio(winner.getPlayerObjId()); AuctionResult result = AuctionResult.WIN_BID; long time = System.currentTimeMillis(); if (winnerHouse != null) { winnerHouse.revokeOwner();//from w w w . j a v a 2 s .c o m } else { int address = HousingService.getInstance().getPlayerAddress(winner.getPlayerObjId()); if (address > 0) { // old house exists winnerHouse = HousingService.getInstance().getHouseByAddress(address); // grace period start, sell time remains from this auction winnerHouse.setSellStarted(new Timestamp(getAuctionStartTime())); // make the new house inactive until the old one is sold obtainedHouse.setStatus(HouseStatus.INACTIVE); result = AuctionResult.GRACE_START; // time = new DateTime((long) (getRunTime() * 1000)).plusWeeks(2).getMillis(); time = new DateTime(getRunTime() * 1000L).plusWeeks(2).getMillis(); } } obtainedHouse.setOwnerId(winner.getPlayerObjId()); if (result == AuctionResult.WIN_BID) { obtainedHouse.setAcquiredTime(new Timestamp(System.currentTimeMillis())); obtainedHouse.setStatus(HouseStatus.ACTIVE); obtainedHouse.setFeePaid(true); obtainedHouse.setNextPay(null); obtainedHouse.setSellStarted(null); obtainedHouse.reloadHouseRegistry(); obtainedHouse.save(); } if (winner.isOnline()) { if (result == AuctionResult.WIN_BID) { winner.getPlayer().setHouseRegistry(obtainedHouse.getRegistry()); winner.getPlayer().setBuildingOwnerState(PlayerHouseOwnerFlags.HOUSE_OWNER.getId()); PacketSendUtility.sendPacket(winner.getPlayer(), new SM_HOUSE_ACQUIRE(winner.getPlayerObjId(), obtainedHouse.getAddress().getId(), true)); PacketSendUtility.sendPacket(winner.getPlayer(), new SM_HOUSE_OWNER_INFO(winner.getPlayer(), obtainedHouse)); } PacketSendUtility.sendPacket(winner.getPlayer(), SM_SYSTEM_MESSAGE.STR_MSG_HOUSING_BID_WIN(obtainedHouse.getAddress().getId())); } MailFormatter.sendHouseAuctionMail(obtainedHouse, winner, result, time, 0); obtainedHouse.getController().kickVisitors(null, true, true); return result; }
From source file:com.aionemu.gameserver.utils.gametime.DateTimeUtil.java
License:Open Source License
public static DateTime getDateTime(String isoDateTime) { DateTime dt = new DateTime(isoDateTime); if (canApplyZoneChange) { return dt.withZoneRetainFields(DateTimeZone.forID(GSConfig.TIME_ZONE_ID)); }//from w w w . j a v a 2s .com return dt; }
From source file:com.aionemu.gameserver.utils.gametime.DateTimeUtil.java
License:Open Source License
public static DateTime getDateTime(GregorianCalendar calendar) { DateTime dt = new DateTime(calendar); if (canApplyZoneChange) { return dt.withZoneRetainFields(DateTimeZone.forID(GSConfig.TIME_ZONE_ID)); }/*from www.j ava 2s .c om*/ return dt; }
From source file:com.aionemu.gameserver.utils.gametime.DateTimeUtil.java
License:Open Source License
public static DateTime getDateTime(long millisSinceSeventies) { DateTime dt = new DateTime(millisSinceSeventies); if (canApplyZoneChange) { return dt.withZoneRetainFields(DateTimeZone.forID(GSConfig.TIME_ZONE_ID)); }/*from w w w . jav a 2s .co m*/ return dt; }
From source file:com.alfaariss.oa.util.saml2.storage.artifact.ArtifactMapEntry.java
License:Open Source License
/** * create a new <code>ArtifactMapEntry</code> using the given values. * // w w w . j a va2 s . co m * @param artifact artifact associated with the message * @param issuer issuer of the artifact * @param relyingParty receiver of the artifact * @param expiration expiration time of the artifact * @param message SAML message mapped to the artifact */ public ArtifactMapEntry(String artifact, String issuer, String relyingParty, long expiration, SAMLObject message) { super(); _artifact = artifact; _issuer = issuer; _relyingParty = relyingParty; _expirationTime = new DateTime(expiration); _message = message; }
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; }/* ww w. j a v a2 s . com*/ 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; }/*www.ja va2 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.adapter.MonthBarChartAdapter.java
License:Open Source License
private void processDutyHours() { List<BarEntry> barDutyEntries = new ArrayList<>(); float xValueCount = 0f; long startMonth = new DateTime(flights.minDate("startDutyTime")).getMonthOfYear(); long currentYear = 0; long currentMonth = 0; 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; if (currentYear == 0 && currentMonth == 0) { currentYear = startDateTime.getYear(); currentMonth = startDateTime.getMonthOfYear(); //Add new entry using day of month as x value BarEntry newEntry = new BarEntry(xValueCount, decHoursDiff); barDutyEntries.add(newEntry); xValueCount++;/* w ww .jav a 2 s . c o m*/ } else { if (currentMonth + 1 < 13) { //Add on any skipped months to xValueCount if (currentMonth + 1 != startDateTime.getMonthOfYear()) { xValueCount += (startDateTime.getMonthOfYear() - currentMonth) - 1; } } //Check if the month is the same as the previous flight // All flights are provided in an ordered list by the repo if (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.getYear() != currentYear) { } //New month //Update these for the next iteration currentYear = startDateTime.getYear(); currentMonth = startDateTime.getMonthOfYear(); //Add new entry using day of month as x value BarEntry newEntry = new BarEntry(xValueCount, decHoursDiff); barDutyEntries.add(newEntry); xValueCount++; } } } IAxisValueFormatter xAxisValueFormatter = new MonthAxisValueFormatter(((int) startMonth - 1)); 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.MonthBarChartAdapter.java
License:Open Source License
private void processFlightHours() { List<BarEntry> barFlightEntries = new ArrayList<>(); float xValueCount = 0f; long startMonth = new DateTime(flights.minDate("startFlightTime")).getMonthOfYear(); long currentYear = 0; long currentMonth = 0; 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; if (currentYear == 0 && currentMonth == 0) { currentYear = startDateTime.getYear(); currentMonth = startDateTime.getMonthOfYear(); //Add new entry using day of month as x value BarEntry newEntry = new BarEntry(xValueCount, decHoursDiff); barFlightEntries.add(newEntry); xValueCount++;/*from w w w . j av a 2s. c om*/ } else { //Check if year wraps around if (currentMonth + 1 < 13) { //Add on any skipped months to xValueCount if (currentMonth + 1 != startDateTime.getMonthOfYear()) { xValueCount += (startDateTime.getMonthOfYear() - currentMonth) - 1; } } //Check if the month is the same as the previous flight // All flights are provided in an ordered list by the repo if (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.getYear() != currentYear) { } //New month //Update these for the next iteration currentYear = startDateTime.getYear(); currentMonth = startDateTime.getMonthOfYear(); //Add new entry using day of month as x value BarEntry newEntry = new BarEntry(xValueCount, decHoursDiff); barFlightEntries.add(newEntry); xValueCount++; } } } IAxisValueFormatter xAxisValueFormatter = new MonthAxisValueFormatter(((int) startMonth - 1)); IAxisValueFormatter yAxisValueFormatter = new DefaultAxisValueFormatter(2); BarDataSet dataSet = new BarDataSet(barFlightEntries, "Flight Hours"); dataSet.setValueTextSize(16f); BarData barDutyData = new BarData(dataSet); barDutyData.setBarWidth(0.9f); barDutyData.setHighlightEnabled(false); view.setupFlightBarChart(barDutyData, xAxisValueFormatter, yAxisValueFormatter); }