List of usage examples for org.joda.time DateTime DateTime
public DateTime(Object instant)
From source file:com.actimem.blog.gson.customtypes.DateTimeAdapter.java
License:Apache License
@Override public DateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return new DateTime(json.getAsString()); }
From source file:com.actimem.blog.jackson.customtypes.DateTimeDeserializer.java
License:Apache License
@Override public DateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { return new DateTime(p.getValueAsString()); }
From source file:com.actimem.blog.jaxb.adapters.DateTimeAdapter.java
License:Apache License
@Override public DateTime unmarshal(String v) throws Exception { return new DateTime(v); }
From source file:com.actionml.DateTimeAdapter.java
License:Apache License
public DateTime deserialize(final JsonElement json, final Type type, final JsonDeserializationContext context) throws JsonParseException { return new DateTime(json.getAsJsonPrimitive().getAsString()); }
From source file:com.addthis.hydra.data.query.op.OpDateFormat.java
License:Apache License
@Override public Bundle rowOp(Bundle row) { BundleColumnBinder binder = getSourceColumnBinder(row); // concatenate columns StringBuffer buf = new StringBuffer(); for (int i = 0; i < incols.length; i++) { String s = ValueUtil.asNativeString(binder.getColumn(row, incols[i])); if (s != null) { buf.append(s);//from www . ja v a 2 s . c o m } } // convert input String sbuf = buf.toString(); DateTime dt = null; if (fromMillis > 0) { dt = new DateTime(Integer.parseInt(sbuf, fromMillis)); } else { dt = inFormat.parseDateTime(sbuf); } // convert and output ValueObject out = null; if (toMillis > 0) { out = ValueFactory.create(dt.getMillis()); } else { out = ValueFactory.create(outFormat.print(dt)); } if (outcol >= row.getCount()) { binder.appendColumn(row, out); } else { binder.setColumn(row, outcol, out); } return row; }
From source file:com.addthis.hydra.job.backup.WeeklyBackup.java
License:Apache License
@Override public String getFormattedDateString(long timeMillis) { // For better handling of days at the end of the year. DateTime dt = new DateTime(timeMillis); if (dt.monthOfYear().get() == 12 && dt.weekOfWeekyear().get() < 3) { return dt.getYearOfCentury() + "53"; }/*from w w w . ja v a 2s .c o m*/ return Integer.toString(dt.getYearOfCentury()) + String.format("%02d", dt.weekOfWeekyear().get()); }
From source file:com.addthis.hydra.job.spawn.SpawnFormattedLogger.java
License:Apache License
private Bundle initBundle(EventType event) { assert (bundleLog != null); Bundle bundle = bundleLog.createBundle(); bundleSetValue(bundle, "CLUSTER", clusterName); bundleSetValue(bundle, "EVENT_TYPE", event.toString()); long time = JitterClock.globalTime(); DateTime dateTime = new DateTime(time); bundleSetValue(bundle, "TIME", time); bundleSetValue(bundle, "DATE_YEAR", dateTime.getYear()); bundleSetValue(bundle, "DATE_MONTH", dateTime.getMonthOfYear()); bundleSetValue(bundle, "DATE_DAY", dateTime.getDayOfMonth()); bundleSetValue(bundle, "FILE_PREFIX_HOUR", "logger-" + String.format("%02d", dateTime.getHourOfDay())); return bundle; }
From source file:com.aionemu.gameserver.network.aion.clientpackets.CM_HOUSE_PAY_RENT.java
License:Open Source License
@Override protected void runImpl() { Player player = getConnection().getActivePlayer(); if (!HousingConfig.ENABLE_HOUSE_PAY) { PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_MSG_F2P_CASH_HOUSE_FEE_FREE); return;/* www . ja v a2s .c o m*/ } House house = player.getActiveHouse(); long toPay = house.getLand().getMaintenanceFee() * weekCount; if (toPay <= 0) { return; } if (player.getInventory().getKinah() < toPay) { PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_NOT_ENOUGH_MONEY); return; } long payTime = house.getNextPay() != null ? house.getNextPay().getTime() : (long) MaintenanceTask.getInstance().getRunTime() * 1000; int counter = weekCount; while ((--counter) >= 0) { payTime += MaintenanceTask.getInstance().getPeriod(); } DateTime nextRun = new DateTime((long) MaintenanceTask.getInstance().getRunTime() * 1000); if (nextRun.plusWeeks(4).isBefore(payTime)) { //client cap return; } player.getInventory().decreaseKinah(toPay); house.setNextPay(new Timestamp(payTime)); house.setFeePaid(true); house.save(); PacketSendUtility.sendPacket(player, new SM_HOUSE_PAY_RENT(weekCount)); }
From source file:com.aionemu.gameserver.services.EventService.java
License:Open Source License
void StartOrMaintainQuests(Player player, ListIterator<Integer> questList, TIntObjectHashMap<List<EventTemplate>> templateMap, boolean start) { while (questList.hasNext()) { int questId = questList.next(); QuestState qs = player.getQuestStateList().getQuestState(questId); QuestEnv cookie = new QuestEnv(null, player, questId, 0); QuestStatus status = qs == null ? QuestStatus.START : qs.getStatus(); if (QuestService.checkLevelRequirement(questId, player.getCommonData().getLevel())) { QuestTemplate template = DataManager.QUEST_DATA.getQuestById(questId); if (template.getRacePermitted() != null) { if (template.getRacePermitted().ordinal() != player.getCommonData().getRace().ordinal()) { continue; }// w ww . ja va 2s. co m } if (template.getClassPermitted().size() != 0) { if (!template.getClassPermitted().contains(player.getCommonData().getPlayerClass())) { continue; } } if (template.getGenderPermitted() != null) { if (template.getGenderPermitted().ordinal() != player.getGender().ordinal()) { continue; } } int amountOfStartConditions = template.getXMLStartConditions().size(); int fulfilledStartConditions = 0; if (amountOfStartConditions != 0) { for (XMLStartCondition startCondition : template.getXMLStartConditions()) { if (startCondition.check(player, false)) { fulfilledStartConditions++; } } if (fulfilledStartConditions < 1) { continue; } } if (qs != null) { if (qs.getCompleteTime() != null || status == QuestStatus.COMPLETE) { DateTime completed = null; if (qs.getCompleteTime() == null) { completed = new DateTime(0); } else { completed = new DateTime(qs.getCompleteTime().getTime()); } if (templateMap.containsKey(questId)) { for (EventTemplate et : templateMap.get(questId)) { // recurring event, reset it if (et.getStartDate().isAfter(completed)) { if (start) { status = QuestStatus.START; qs.setQuestVar(0); qs.setCompleteCount(0); qs.setStatus(status); } break; } } } } // re-register quests if (status == QuestStatus.COMPLETE) { PacketSendUtility.sendPacket(player, new SM_QUEST_ACTION(questId, status, qs.getQuestVars().getQuestVars())); } else { QuestService.startEventQuest(cookie, status); } } else if (start) { QuestService.startEventQuest(cookie, status); } } } }
From source file:com.aionemu.gameserver.services.HousingBidService.java
License:Open Source License
public boolean isBiddingAllowed() { DateTime now = DateTime.now();/* w w w . j ava 2s . c o m*/ DateTime auctionEnd = new DateTime(((long) getRunTime() + timeProlonged * 60) * 1000); if (now.getDayOfWeek() == auctionEnd.getDayOfWeek() && auctionEnd.minusDays(1).isAfterNow()) { // Auction is unavailable from Sunday 12 PM to Monday return false; } return true; }