List of usage examples for org.joda.time LocalDateTime now
public static LocalDateTime now()
ISOChronology
in the default time zone. From source file:com.nkapps.billing.dao.PaymentDaoImpl.java
@Override public void updatePaymentManual(BigDecimal paymentId, String tin, String paymentNum, Date paymentDate, BigDecimal paymentSum, String tinDebtor, Long issuerSerialNumber, String issuerIp) throws Exception { Session session = getSession();//from w ww . j av a 2 s. c o m Transaction transaction = session.beginTransaction(); String q = " SELECT p.id AS id, p.tin AS tin, p.paymentNum AS paymentNum, p.paymentDate AS paymentDate," + " p.paymentSum AS paymentSum, p.sourceCode AS sourceCode," + " p.state AS state, p.tinDebtor as tinDebtor,p.claim as claim, p.issuerSerialNumber as issuerSerialNumber," + " p.issuerIp as issuerIp,p.dateCreated AS dateCreated, p.dateUpdated as dateUpdated, " + " p.paymentSum - COALESCE((SELECT SUM(paidSum) FROM KeyPayment kp WHERE kp.payment = p),0) AS overSum " + " FROM Payment p " + " WHERE p.id = :paymentId "; Query query = session.createQuery(q); query.setParameter("paymentId", paymentId); query.setResultTransformer(Transformers.aliasToBean(Payment.class)); Payment payment = (Payment) query.uniqueResult(); // checking paymentsum >= key sum - (payment.payment_sum - payment.over_sum) short state; if (paymentSum.compareTo(payment.getPaymentSum().subtract(payment.getOverSum())) <= 0) { paymentSum = payment.getPaymentSum().subtract(payment.getOverSum()); state = 3; } else { if (payment.getPaymentSum().compareTo(payment.getOverSum()) == 0) { state = 1; } else { state = 2; } } payment.setTin(tin); payment.setPaymentNum(paymentNum); payment.setPaymentDate(paymentDate); payment.setPaymentSum(paymentSum); payment.setState(state); payment.setTinDebtor(tinDebtor); payment.setIssuerSerialNumber(issuerSerialNumber); payment.setIssuerIp(issuerIp); LocalDateTime dateTime = LocalDateTime.now(); payment.setDateUpdated(dateTime); session.update(payment); transaction.commit(); session.close(); }
From source file:com.nkapps.billing.dao.PgDaoImpl.java
@Override public void clickSave(ClickPojo clickPojo) throws Exception { Session session = getSession();/* ww w . j a v a 2 s . co m*/ Transaction transaction = session.beginTransaction(); Click click = (Click) session.get(Click.class, clickPojo.getId()); LocalDateTime dateTime = LocalDateTime.now(); if (click == null) { click = new Click(); click.setId(clickPojo.getId()); click.setTransactionId(clickPojo.getClickTransId()); click.setTin(clickPojo.getMerchantTransId()); click.setPaymentDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(clickPojo.getSignTime())); click.setPaymentSum(clickPojo.getAmount()); click.setDateCreated(dateTime); click.setDateUpdated(dateTime); session.save(click); Payment payment = new Payment(); payment.setTin(click.getTin()); payment.setPaymentNum(click.getTransactionId().toString()); payment.setPaymentDate(click.getPaymentDate()); payment.setPaymentSum(click.getPaymentSum()); // payment.setSourceCode((short) 3); // for click payment.setState((short) 1); // payment.setClaim((short) 0); // payment.setDateCreated(dateTime); payment.setDateUpdated(dateTime); session.save(payment); ClickPayment cp = new ClickPayment(); ClickPaymentId cpId = new ClickPaymentId(); cpId.setClick(click); cpId.setPayment(payment); cp.setId(cpId); session.save(cp); } else { click.setDateUpdated(dateTime); session.update(click); } transaction.commit(); session.close(); }
From source file:com.nkapps.billing.dao.PgDaoImpl.java
@Override public void smstSave(SmstPojo smstPojo) throws Exception { Session session = getSession();//ww w . jav a 2 s.co m Transaction transaction = session.beginTransaction(); Smst smst = (Smst) session.get(Smst.class, smstPojo.getId()); LocalDateTime dateTime = LocalDateTime.now(); if (smst == null) { smst = new Smst(); smst.setId(smstPojo.getId()); smst.setTransactionId(smstPojo.getSmstTransId()); smst.setTin(smstPojo.getMerchantTransId()); smst.setPaymentDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(smstPojo.getSignTime())); smst.setPaymentSum(smstPojo.getAmount()); smst.setDateCreated(dateTime); smst.setDateUpdated(dateTime); session.save(smst); Payment payment = new Payment(); payment.setTin(smst.getTin()); payment.setPaymentNum(smst.getTransactionId().toString()); payment.setPaymentDate(smst.getPaymentDate()); payment.setPaymentSum(smst.getPaymentSum()); // payment.setSourceCode((short) 4); // for smst payment.setState((short) 1); // payment.setClaim((short) 0); // payment.setDateCreated(dateTime); payment.setDateUpdated(dateTime); session.save(payment); SmstPayment sp = new SmstPayment(); SmstPaymentId spId = new SmstPaymentId(); spId.setSmst(smst); spId.setPayment(payment); sp.setId(spId); session.save(sp); } else { smst.setDateUpdated(dateTime); session.update(smst); } transaction.commit(); session.close(); }
From source file:com.nkapps.billing.dao.PgDaoImpl.java
@Override public void munisSave(MunisPojo munisPojo) throws Exception { Session session = getSession();// w ww .j av a 2 s.c om Transaction transaction = session.beginTransaction(); Munis munis = (Munis) session.get(Munis.class, new BigInteger(munisPojo.getPaymentId())); LocalDateTime dateTime = LocalDateTime.now(); if (munis == null) { munis = new Munis(); munis.setId(new BigInteger(munisPojo.getPaymentId())); munis.setConfirmCode(munisPojo.getConfirmCode()); munis.setConfirmMessage(munisPojo.getConfirmMessage()); munis.setSysinfoData(munisPojo.getSysinfoData()); munis.setSysinfoTime(munisPojo.getSysinfoTime()); munis.setSysinfoBid(munisPojo.getSysinfoBid()); munis.setSysinfoTid(munisPojo.getSysinfoTid()); munis.setSysinfoSid(munisPojo.getSysinfoSid()); munis.setSysinfoHash(munisPojo.getSysinfoHash()); munis.setPayerBranch(munisPojo.getPayerBranch()); munis.setPayerAccount(munisPojo.getPayerAccount()); munis.setPayerName(munisPojo.getPayerName()); munis.setPayerInn(munisPojo.getPayerInn()); munis.setPayeeBranch(munisPojo.getPayeeBranch()); munis.setPayeeAccount(munisPojo.getPayeeAccount()); munis.setPayeeName(munisPojo.getPayeeName()); munis.setPayeeInn(munisPojo.getPayeeInn()); munis.setPurposeCode(munisPojo.getPurposeCode()); munis.setPurposeText(munisPojo.getPurposeText()); munis.setAmountCurrency(munisPojo.getAmountCurrency()); munis.setAmountValue(new BigDecimal(munisPojo.getAmountValue()).divide(new BigDecimal("100"))); // tiyin convert to so'm munis.setDocumentNum(StringUtils.leftPad(munisPojo.getDocumentNum(), 10, "0")); munis.setDocumentData(new SimpleDateFormat("dd.MM.yyyy").parse(munisPojo.getDocumentData())); munis.setSettlementSupplier(munisPojo.getSettlementSupplier()); munis.setSettlementCode(munisPojo.getSettlementCode()); munis.setSubjectinfoGni(munisPojo.getSubjectinfoGni()); munis.setSubjectinfoInn(munisPojo.getSubjectinfoInn()); munis.setSubjectinfoCodeObj(munisPojo.getSubjectinfoCodeObj()); munis.setInfoserviceInn(munisPojo.getInfoserviceInn()); munis.setInfoserviceName(munisPojo.getInfoserviceName()); munis.setInfoserviceCodeObj(munisPojo.getInfoserviceCodeObj()); munis.setInfoserviceAddressObj(munisPojo.getInfoserviceAddressObj()); munis.setDateCreated(dateTime); munis.setDateUpdated(dateTime); session.save(munis); Payment payment = paymentDao.findPayment(munis.getSubjectinfoInn(), munis.getDocumentNum(), munis.getDocumentData(), munis.getAmountValue(), munis.getPayerInn(), (short) 1); // bank statement payment to search if (payment == null) { payment = new Payment(); payment.setTin(munis.getSubjectinfoInn()); payment.setPaymentNum(munis.getDocumentNum()); payment.setPaymentDate(munis.getDocumentData()); payment.setPaymentSum(munis.getAmountValue()); // payment.setTinDebtor(munis.getPayerInn()); payment.setSourceCode((short) 2); // for munis payment.setState((short) 1); // payment.setClaim((short) 0); // payment.setDateCreated(dateTime); payment.setDateUpdated(dateTime); session.save(payment); MunisPayment mp = new MunisPayment(); MunisPaymentId mpId = new MunisPaymentId(); mpId.setMunis(munis); mpId.setPayment(payment); mp.setId(mpId); session.save(mp); } else { BankStatementMunis bsm = new BankStatementMunis(); BankStatementMunisId bsmId = new BankStatementMunisId(); bsmId.setBankStatement(payment.getBankStatementPayment().getId().getBankStatement()); bsmId.setMunis(munis); bsm.setId(bsmId); session.save(bsm); } } else { munis.setDateUpdated(dateTime); session.update(munis); } transaction.commit(); session.close(); }
From source file:com.nkapps.billing.dao.WSDaoImpl.java
@Override public WsUser createWsUser(String username, String password) { Session session = getSession();/*from ww w .j a va 2 s. c om*/ Transaction transaction = session.beginTransaction(); WsUser user = null; try { LocalDateTime dateTime = LocalDateTime.now(); Query query = session.createQuery( "UPDATE WsUser u SET u.active = 0, u.dateUpdated = :dateUpdated WHERE u.username = :username"); query.setParameter("dateUpdated", dateTime); query.setParameter("username", username); query.executeUpdate(); user = new WsUser(); user.setUsername(username); user.setPassword(password); user.setType((short) 1); user.setActive((short) 1); user.setDateCreated(dateTime); user.setDateUpdated(dateTime); session.save(user); session.flush(); transaction.commit(); } catch (Exception e) { transaction.rollback(); } session.close(); return user; }
From source file:com.nkapps.billing.services.BankStatementServiceImpl.java
@Override public String parseAndSave(File file, Long issuerSerialNumber, String issuerIp) throws Exception { String errorMessages = ""; FileInputStream fis = new FileInputStream(file); BufferedReader br = new BufferedReader(new InputStreamReader(fis, "windows-1251")); List<BankStatement> bsList = new ArrayList<>(); LocalDateTime dateTime = LocalDateTime.now(); boolean skipFirstLine = true; String line;//from w ww . j a v a2s. co m int lineCurrent = 0; while ((line = br.readLine()) != null) { lineCurrent++; if (skipFirstLine) { skipFirstLine = false; continue; } line = replaceCyrillic(line); String[] cols = line.split("#"); /*** * * detali platejdagi '#' simvolni togirlash * * int colSize = cols.length; for (int j = 0; j < colSize - 8; j++) { cols[4] = cols[4] + cols[5]; List<String> temp = new ArrayList<String>(Arrays.asList(cols)); temp.remove(5); cols = temp.toArray(new String[0]); } */ if (cols.length > 8) { /*** * * First of all we must define where contains # , or payment details or name, * maximum two # symbols we can convert, one of contains detail, another of contains name * */ int overSize = cols.length - 8; if (overSize == 1) { String dateStr = cols[7]; // if dateStr is date then paymentdetails contains #, else name contains # boolean detailContains = true; SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yy"); try { dateFormat.parse(dateStr); } catch (ParseException e) { detailContains = false; } if (detailContains) { cols[4] = cols[4] + cols[5]; List<String> temp = new ArrayList<>(Arrays.asList(cols)); temp.remove(5); cols = temp.toArray(new String[temp.size()]); } else { cols[7] = cols[7] + cols[8]; List<String> temp = new ArrayList<>(Arrays.asList(cols)); temp.remove(8); cols = temp.toArray(new String[temp.size()]); } } else if (overSize == 2) { // first details contains 2 # String dateStr = cols[8]; boolean detailTwoContains = true; SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yy"); try { dateFormat.parse(dateStr); } catch (ParseException e) { detailTwoContains = false; } if (detailTwoContains) { // cols[4] = cols[4] + cols[5] + cols[6]; List<String> temp = new ArrayList<>(Arrays.asList(cols)); temp.remove(5); temp.remove(6); cols = temp.toArray(new String[temp.size()]); } else { dateStr = cols[6]; boolean nameTwoContains = true; dateFormat = new SimpleDateFormat("dd.MM.yy"); try { dateFormat.parse(dateStr); } catch (ParseException e) { nameTwoContains = false; } if (nameTwoContains) { // cols[7] = cols[7] + cols[8] + cols[9]; List<String> temp = new ArrayList<>(Arrays.asList(cols)); temp.remove(8); temp.remove(9); cols = temp.toArray(new String[temp.size()]); } else { dateStr = cols[7]; boolean nameAndDetailsContains = true; dateFormat = new SimpleDateFormat("dd.MM.yy"); try { dateFormat.parse(dateStr); } catch (ParseException e) { nameAndDetailsContains = false; } if (nameAndDetailsContains) { // cols[4] = cols[4] + cols[5]; cols[8] = cols[8] + cols[9]; List<String> temp = new ArrayList<>(Arrays.asList(cols)); temp.remove(5); temp.remove(9); cols = temp.toArray(new String[temp.size()]); } } } } } if (cols.length == 8) { try { BankStatement bs = bsFromCols(cols, issuerSerialNumber, issuerIp, dateTime); bsList.add(bs); } catch (Exception e) { errorMessages += messageSource.getMessage("upload.error_convert_bs", null, LocaleContextHolder.getLocale()) + " " + lineCurrent + " <br/>"; } } else { errorMessages += messageSource.getMessage("upload.error_over_columns", null, LocaleContextHolder.getLocale()) + " " + lineCurrent + " <br/>"; } } br.close(); fis.close(); bankStatementDao.saveBankStatements(bsList); bankStatementDao.saveToPayment(); bankStatementDao.saveToReportClick(); bankStatementDao.saveToReportSmst(); return errorMessages; }
From source file:com.prayer.vakit.WidgetProviderClock2.java
License:Apache License
public static void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int widgetId) { if (mDP == 0) { Resources r = context.getResources(); mDP = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, r.getDisplayMetrics()); }/* w ww. ja v a2 s. c o m*/ Resources r = context.getResources(); SharedPreferences widgets = context.getSharedPreferences("widgets", 0); int w = widgets.getInt(widgetId + "_width", 500); int h = widgets.getInt(widgetId + "_height", 200); w = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, w, r.getDisplayMetrics()); h = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, h, r.getDisplayMetrics()); float scaleX = (float) w / (float) 2; float scaleY = (float) h / (float) 2; float scale = Math.min(scaleY, scaleX); w = (int) (2 * scale); h = (int) (2 * scale); if ((w <= 0) || (h <= 0)) { SharedPreferences.Editor edit = widgets.edit(); edit.remove(widgetId + "_width"); edit.remove(widgetId + "_height"); edit.apply(); updateAppWidget(context, appWidgetManager, widgetId); return; } Times times = null; long id = 0; try { id = widgets.getLong(widgetId + "", 0L); } catch (ClassCastException e) { widgets.edit().remove(widgetId + "").apply(); } if (id != 0) { times = Times.getTimes(id); } if (times == null) { RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_city_removed_prayer); Intent i = new Intent(context, WidgetConfigureClock.class); i.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId); remoteViews.setOnClickPendingIntent(R.id.image, PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT)); appWidgetManager.updateAppWidget(widgetId, remoteViews); return; } RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.vakit_widget_prayer); remoteViews.setOnClickPendingIntent(R.id.main, Main.getPendingIntent(times)); Bitmap bmp = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_4444); Canvas canvas = new Canvas(bmp); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setDither(true); paint.setFilterBitmap(true); paint.setStyle(Style.STROKE); paint.setAntiAlias(true); paint.setSubpixelText(true); paint.setShadowLayer(2, 2, 2, 0xFF555555); paint.setTextAlign(Align.CENTER); paint.setColor(Color.WHITE); paint.setColor(0xFFFFFFFF); paint.setStrokeWidth(w / 100); canvas.drawArc(new RectF(w / 100, w / 100, w - w / 100, h - w / 100), 0, 360, false, paint); boolean isKerahat = times.isKerahat(); if (isKerahat) { paint.setColor(0xffbf3f5b); } else { paint.setColor(ContextCompat.getColor(context, R.color.accent)); } int next = times.getNext(); int last = next - 1; if (Prefs.getVakitIndicator().equals("next")) last++; canvas.drawArc(new RectF(w / 100, w / 100, w - w / 100, h - w / 100), -90, times.getPassedPart() * 360, false, paint); paint.setStrokeWidth(1); LocalDateTime ltime = LocalDateTime.now(); String[] time = Utils.fixTime(ltime.toString("HH:mm")).replace(":", " ").split(" "); paint.setTextSize(h * 0.50f); paint.setStyle(Style.FILL); paint.setColor(Color.WHITE); if (time.length == 3) { paint.setTextAlign(Align.RIGHT); canvas.drawText(time[0], w * 0.59f, h * 0.65f, paint); paint.setTextAlign(Align.LEFT); if (isKerahat) { paint.setColor(0xffbf3f5b); } else { paint.setColor(ContextCompat.getColor(context, R.color.accent)); } paint.setTextSize(h * 0.18f); canvas.drawText(time[1], w * 0.60f, h * 0.45f, paint); paint.setTextSize(h * 0.1f); paint.setTextSize(h * 0.1f); canvas.drawText(time[2], w * 0.80f, h * 0.45f, paint); paint.setColor(0xFFFFFFFF); paint.setTextSize(h * 0.07f); canvas.drawText(Utils.toArabicNrs(ltime.toString("d'.' MMM'.'")), w * 0.60f, h * 0.55f, paint); canvas.drawText(Vakit.getByIndex(last).getString(), w * 0.60f, h * 0.65f, paint); } else { paint.setTextAlign(Align.RIGHT); canvas.drawText(time[0], w * 0.62f, h * 0.65f, paint); paint.setTextAlign(Align.LEFT); if (isKerahat) { paint.setColor(0xffbf3f5b); } else { paint.setColor(ContextCompat.getColor(context, R.color.accent)); } paint.setTextSize(h * 0.22f); canvas.drawText(time[1], w * 0.63f, h * 0.45f, paint); paint.setColor(0xFFFFFFFF); paint.setTextSize(h * 0.07f); canvas.drawText(Utils.toArabicNrs(ltime.toString("d'.' MMM'.'")), w * 0.63f, h * 0.55f, paint); canvas.drawText(Vakit.getByIndex(last).getString(), w * 0.63f, h * 0.65f, paint); } paint.setTextAlign(Align.CENTER); paint.setTextSize(h * 0.15f); canvas.drawText(times.getLeft(next, false), w / 2, h * 0.85f, paint); paint.setTextSize(h * 0.12f); canvas.drawText(ltime.toString("EEEE"), w / 2, h * 0.22f, paint); remoteViews.setImageViewBitmap(R.id.widget, bmp); try { appWidgetManager.updateAppWidget(widgetId, remoteViews); } catch (RuntimeException e) { if (!e.getMessage().contains("exceeds maximum bitmap memory usage")) { } } }
From source file:com.rusticisoftware.tincan.internal.DateTime.java
License:Apache License
public DateTime() { this.dateTime = new hirondelle.date4j.DateTime(LocalDateTime.now().toString()); }
From source file:com.sandata.lab.wcf.lookup.impl.RestLookupTablesService.java
License:Open Source License
private boolean lastCacheUpdateTimeExpired(final SandataLogger logger) { boolean bResult = false; String method = logger.getMethodName(); logger.setMethodName("lastCacheUpdateTimeExpired"); LocalDateTime now = LocalDateTime.now(); Duration duration = new Duration(lastCacheUpdateTime.toDateTime(DateTimeZone.UTC), now.toDateTime(DateTimeZone.UTC)); long seconds = duration.getStandardSeconds(); long minutes = duration.getStandardMinutes(); logger.info(String.format("Last Cache Update: %s", TimeFormat.SecondsToString(seconds))); if (minutes >= updateCacheInterval) { bResult = true;/* w ww . j av a 2 s. c o m*/ } logger.setMethodName(method); return bResult; }
From source file:controllers.PrettyTimeController.java
License:Apache License
public Result index(Context context) { // Only render the page. It contains some language specific strings. // It will use the requested language (or a fallback language) // from Accept-Language header Result result = Results.html(); // just in case we set the language => we remove it... lang.clearLanguage(result);//from w w w . j ava2s. c o m // 25 works for summertime, too. LocalDateTime localDateTime = LocalDateTime.now().minusHours(25); result.render("date", new Date(localDateTime.toDateTime().getMillis())); return result; }