List of usage examples for org.joda.time DateTime now
public static DateTime now()
ISOChronology
in the default time zone. From source file:com.ac.mule.stripe.CreditCardTokenGenerator.java
License:Open Source License
public static Map<String, Object> generateCreditCardToken() throws Exception { Map<String, Object> tokenParams = new HashMap<String, Object>(); Map<String, Object> cardParams = new HashMap<String, Object>(); cardParams.put("number", "4242424242424242"); cardParams.put("exp_month", 4); cardParams.put("exp_year", DateTime.now().getYear() + 1); cardParams.put("cvc", "314"); tokenParams.put("card", cardParams); return tokenParams; }
From source file:com.ac.mule.stripe.CreditCardTokenGenerator.java
License:Open Source License
public static Map<String, Object> generateCreditCardTokenFailCVC() throws Exception { Map<String, Object> tokenParams = new HashMap<String, Object>(); Map<String, Object> cardParams = new HashMap<String, Object>(); cardParams.put("number", "4000000000000127"); cardParams.put("exp_month", 4); cardParams.put("exp_year", DateTime.now().getYear() + 1); cardParams.put("cvc", "314"); tokenParams.put("card", cardParams); return tokenParams; }
From source file:com.ac.mule.stripe.CreditCardTokenGenerator.java
License:Open Source License
public static Map<String, Object> generateCreditCardTokenFailExpired() throws Exception { Map<String, Object> tokenParams = new HashMap<String, Object>(); Map<String, Object> cardParams = new HashMap<String, Object>(); cardParams.put("number", "4000000000000069"); cardParams.put("exp_month", 4); cardParams.put("exp_year", DateTime.now().getYear() + 1); cardParams.put("cvc", "314"); tokenParams.put("card", cardParams); return tokenParams; }
From source file:com.ac.mule.stripe.CreditCardTokenGenerator.java
License:Open Source License
public static Map<String, Object> generateCreditCardTokenFail() throws Exception { Map<String, Object> tokenParams = new HashMap<String, Object>(); Map<String, Object> cardParams = new HashMap<String, Object>(); cardParams.put("number", "4000000000000119"); cardParams.put("exp_month", 4); cardParams.put("exp_year", DateTime.now().getYear() + 1); cardParams.put("cvc", "314"); tokenParams.put("card", cardParams); return tokenParams; }
From source file:com.ac.mule.stripe.CreditCardTokenGenerator.java
License:Open Source License
public static Map<String, Object> generateCreditCardTokenDeclineCharge() throws Exception { Map<String, Object> tokenParams = new HashMap<String, Object>(); Map<String, Object> cardParams = new HashMap<String, Object>(); cardParams.put("number", "4000000000000341"); cardParams.put("exp_month", 4); cardParams.put("exp_year", DateTime.now().getYear() + 1); cardParams.put("cvc", "314"); tokenParams.put("card", cardParams); return tokenParams; }
From source file:com.ace.erp.service.sys.impl.UserServiceImpl.java
/** * ?//from ww w . ja v a 2 s. c o m * @param user * @return * @throws com.ace.erp.exception.AceException */ public User save(User user) throws AceException { user.randomSalt(); user.setPassword(encryptPassword(user.getUsername(), user.getPassword(), user.getSalt())); if (user.getCreateTime() == null) { user.setCreateTime(DateTime.now().toString(TimeUtils.DATETIME_NORMAL_FORMAT)); } else { user.setCreateTime("2013-10-17"); } super.save(user); logger.info("insert successfully, user {}", user); return user; }
From source file:com.ace.erp.service.sys.impl.UserServiceImpl.java
/** * ?/*from w w w .ja va2 s . co m*/ * @param user * @return * @throws AceException */ public User saveUserOrOrganization(User user) throws AceException { user.randomSalt(); user.setPassword(encryptPassword(user.getUsername(), user.getPassword(), user.getSalt())); if (user.getCreateTime() == null) { user.setCreateTime(DateTime.now().toString(TimeUtils.DATETIME_NORMAL_FORMAT)); } //step1 super.save(user); UserOrganization userOrganization = null; //step2 ?? //TODO Organization organization = user.getOrganizationList() == null ? null : user.getOrganizationList().get(0); if (organization == null) { organization = new Organization(user.getUsername(), 1, 2); organizationMapper.save(organization); } else { organizationMapper.save(organization); } userOrganization = new UserOrganization(user, organization); //step3 ??? userMapper.saveUserOrganization(userOrganization); //step4 ??? //TODO ????,?? Role role = roleMapper.getSysAdminRole(); userMapper.saveUserRoles(new UserRoles(user, role, organization)); logger.info("insert successfully, user {}", user); return user; }
From source file:com.act.lcms.v2.fullindex.Builder.java
License:Open Source License
public void processScan(List<Double> targetMZs, File scanFile) throws RocksDBException, ParserConfigurationException, XMLStreamException, IOException { DateTime start = DateTime.now(); LOGGER.info("Accessing scan file at %s", scanFile.getAbsolutePath()); LCMSNetCDFParser parser = new LCMSNetCDFParser(); Iterator<LCMSSpectrum> spectrumIterator = parser.getIterator(scanFile.getAbsolutePath()); WriteOptions writeOptions = new WriteOptions(); /* The write-ahead log and disk synchronization features are useful when we need our writes to be durable (i.e. to * survive a crash). However, our index construction is effectively a one-shot deal: if it doesn't succeed, we'll * just start from scratch. Since we don't care about durability while we're constructing the index, the WAL and * sync features eat a lot of disk space and I/O bandwidth, which slows us down. So long as we cleanly close the * index once it's built, nobody has to know that we disabled these features. */ writeOptions.setDisableWAL(true);/*from w w w .j a va2 s .com*/ writeOptions.setSync(false); dbAndHandles.setWriteOptions(writeOptions); // TODO: split targetMZs into batches of ~100k and extract incrementally to allow huge input sets. LOGGER.info("Extracting traces"); List<MZWindow> windows = targetsToWindows(targetMZs); extractTriples(spectrumIterator, windows); LOGGER.info("Writing search targets to on-disk index"); writeWindowsToDB(windows); DateTime end = DateTime.now(); LOGGER.info("Index construction completed in %dms", end.getMillis() - start.getMillis()); }
From source file:com.act.lcms.v2.fullindex.Searcher.java
License:Open Source License
/** * Searches an LCMS index for all (time, m/z, intensity) triples within some time and m/z ranges. * * Note that this method is very much a first-draft/WIP. There are many opportunities for optimization and * improvement here, but this works as an initial attempt. This method is littered with TODOs, which once TODone * should make this a near optimal method of searching through LCMS readings. * * @param mzRange The range of m/z values for which to search. * @param timeRange The time range for which to search. * @return A list of (time, m/z, intensity) triples that fall within the specified ranges. * @throws RocksDBException//from www . jav a2s . com * @throws ClassNotFoundException * @throws IOException */ public List<TMzI> searchIndexInRange(Pair<Double, Double> mzRange, Pair<Double, Double> timeRange) throws RocksDBException, ClassNotFoundException, IOException { // TODO: gracefully handle the case when only range is specified. // TODO: consider producing some sort of query plan structure that can be used for optimization/explanation. DateTime start = DateTime.now(); /* Demote the time range to floats, as we know that that's how we stored times in the DB. This tight coupling would * normally be a bad thing, but given that this class is joined at the hip with Builder necessarily, it * doesn't seem like a terrible thing at the moment. */ Pair<Float, Float> tRangeF = // My kingdom for a functor! Pair.of(timeRange.getLeft().floatValue(), timeRange.getRight().floatValue()); LOGGER.info("Running search for %.6f <= t <= %.6f, %.6f <= m/z <= %.6f", tRangeF.getLeft(), tRangeF.getRight(), mzRange.getLeft(), mzRange.getRight()); // TODO: short circuit these filters. The first failure after success => no more possible hits. List<Float> timesInRange = timepointsInRange(tRangeF); byte[][] timeIndexBytes = extractValueBytes(ColumnFamilies.TIMEPOINT_TO_TRIPLES, timesInRange, Float.BYTES, ByteBuffer::putFloat); // TODO: bail if all the timeIndexBytes lengths are zero. List<MZWindow> mzWindowsInRange = mzWindowsInRange(mzRange); byte[][] mzIndexBytes = extractValueBytes(ColumnFamilies.WINDOW_ID_TO_TRIPLES, mzWindowsInRange, Integer.BYTES, (buff, mz) -> buff.putInt(mz.getIndex())); // TODO: bail if all the mzIndexBytes are zero. /* TODO: if the number of entries in one range is significantly smaller than the other (like an order of magnitude * or more, skip extraction of the other set of ids and just filter at the end. This will be especially helpful * when the number of ids in the m/z domain is small, as each time point will probably have >10k ids. */ LOGGER.info("Found/loaded %d matching time ranges, %d matching m/z ranges", timesInRange.size(), mzWindowsInRange.size()); // TODO: there is no need to union the time indices since they are necessarily distinct. Just concatenate instead. Set<Long> unionTimeIds = unionIdBuffers(timeIndexBytes); Set<Long> unionMzIds = unionIdBuffers(mzIndexBytes); // TODO: handle the case where one of the sets is empty specially. Either keep all in the other set or drop all. // TODO: we might be able to do this faster by intersecting two sorted lists. Set<Long> intersectionIds = new HashSet<>(unionTimeIds); /* TODO: this is effectively a hash join, which isn't optimal for sets of wildly different cardinalities. * Consider using sort-merge join instead, which will reduce the object overhead (by a lot) and allow us to pass * over the union of the ids from each range just once when joining them. Additionally, just skip this whole step * and filter at the end if one of the set's sizes is less than 1k or so and the other is large. */ intersectionIds.retainAll(unionMzIds); LOGGER.info("Id intersection results: t = %d, mz = %d, t ^ mz = %d", unionTimeIds.size(), unionMzIds.size(), intersectionIds.size()); List<Long> idsToFetch = new ArrayList<>(intersectionIds); Collections.sort(idsToFetch); // Sort ids so we retrieve them in an order that exploits index locality. LOGGER.info("Collecting TMzI triples"); // Collect all the triples for the ids we extracted. // TODO: don't manifest all the bytes: just create a stream of results from the cursor to reduce memory overhead. List<TMzI> results = new ArrayList<>(idsToFetch.size()); byte[][] resultBytes = extractValueBytes(ColumnFamilies.ID_TO_TRIPLE, idsToFetch, Long.BYTES, ByteBuffer::putLong); for (byte[] tmziBytes : resultBytes) { results.add(TMzI.readNextFromByteBuffer(ByteBuffer.wrap(tmziBytes))); } // TODO: do this filtering inline with the extraction. We shouldn't have to load all the triples before filtering. LOGGER.info("Performing final filtering"); int preFilterTMzICount = results.size(); results = results.stream() .filter(tmzi -> tmzi.getTime() >= tRangeF.getLeft() && tmzi.getTime() <= tRangeF.getRight() && tmzi.getMz() >= mzRange.getLeft() && tmzi.getMz() <= mzRange.getRight()) .collect(Collectors.toList()); LOGGER.info("Precise filtering results: %d -> %d", preFilterTMzICount, results.size()); DateTime end = DateTime.now(); LOGGER.info("Search completed in %dms", end.getMillis() - start.getMillis()); // TODO: return a stream instead that can load the triples lazily. return results; }
From source file:com.aionemu.gameserver.dataholders.InstanceCooltimeData.java
License:Open Source License
public long getInstanceEntranceCooltime(Player player, int worldId) { int instanceCooldownRate = InstanceService.getInstanceRate(player, worldId); long instanceCoolTime = 0; InstanceCooltime clt = getInstanceCooltimeByWorldId(worldId); if (clt != null) { instanceCoolTime = clt.getEntCoolTime(); if (clt.getCoolTimeType().isDaily()) { DateTime now = DateTime.now(); DateTime repeatDate = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), (int) (instanceCoolTime / 100), 0, 0); if (now.isAfter(repeatDate)) { repeatDate = repeatDate.plusHours(24); instanceCoolTime = repeatDate.getMillis(); } else { instanceCoolTime = repeatDate.getMillis(); }//from w w w. j av a 2s. c o m } else if (clt.getCoolTimeType().isWeekly()) { String[] days = clt.getTypeValue().split(","); instanceCoolTime = getUpdateHours(days, (int) (instanceCoolTime / 100)); } else { instanceCoolTime = System.currentTimeMillis() + (instanceCoolTime * 60 * 1000); } } if (instanceCooldownRate != 1) { instanceCoolTime = System.currentTimeMillis() + ((instanceCoolTime - System.currentTimeMillis()) / instanceCooldownRate); } return instanceCoolTime; }