List of usage examples for org.joda.time LocalDateTime now
public static LocalDateTime now()
ISOChronology
in the default time zone. From source file:com.hpe.software.utils.Utils.java
License:Apache License
/** * Checks if authentication will expire/*w w w . j a v a 2s . c o m*/ * @param conf * @param agmConnector * @throws AuthenticationException * @throws BadResponseException */ public static LocalDateTime checkForExpiration(LocalDateTime expires, Configuration conf, AgmConnector agmConnector) throws AuthenticationException, BadResponseException { LocalDateTime retValue = expires; if (LocalDateTime.now().isAfter(retValue)) { retValue = Utils.connectToAgM(conf, agmConnector); } return retValue; }
From source file:com.kccomy.orgar.ui.editor.NodeEditorFragment.java
License:Apache License
private void showDatePickerDialog(OrgTimestamp.Type type) { LocalDateTime src = null;/*ww w . j av a2 s . c o m*/ if (OrgTimestamp.Type.SCHEDULED.equals(type)) { src = scheduledDate; } else if (OrgTimestamp.Type.DEADLINE.equals(type)) { src = deadlineDate; } LocalDateTime date = src != null ? src : LocalDateTime.now(); DatePickerDialog picker = DatePickerDialog.newInstance(this, date.getYear(), date.getMonthOfYear(), date.getDayOfMonth()); picker.setAccentColor(getResources().getColor(R.color.colorAccent)); picker.show(getActivity().getFragmentManager(), type.toString()); }
From source file:com.kccomy.orgar.util.DateFormatUtil.java
License:Apache License
public static String getFormattedDate(Date date) { LocalDateTime modified = LocalDateTime.fromDateFields(date); LocalDateTime now = LocalDateTime.now(); if (modified.getWeekOfWeekyear() == now.getWeekOfWeekyear() && modified.getYear() == now.getYear()) { if (modified.getDayOfWeek() == now.getDayOfWeek()) { return modified.toString(TIME); } else {/*w ww . j a v a2 s . com*/ return modified.toString(WEEK); } } else { return modified.toString(DATE); } }
From source file:com.metinkale.prayerapp.vakit.times.Times.java
License:Apache License
public String getLeft(int next, boolean showsecs) { LocalDateTime date = getTimeCal(null, next); Period period = new Period(LocalDateTime.now(), date, PeriodType.dayTime()); if (showsecs) { return Utils.toArabicNrs(PERIOD_FORMATTER_HMS.print(period)); } else if (Prefs.isDefaultWidgetMinuteType()) { return Utils.toArabicNrs(PERIOD_FORMATTER_HM.print(period)); } else {//from ww w .j a v a 2 s . c om period = period.withFieldAdded(DurationFieldType.minutes(), 1); return Utils.toArabicNrs(PERIOD_FORMATTER_HM.print(period)); } }
From source file:com.metinkale.prayerapp.vakit.times.Times.java
License:Apache License
public int getLeftMinutes(int which) { LocalDateTime date = getTimeCal(null, which); Period period = new Period(LocalDateTime.now(), date, PeriodType.minutes()); return period.getMinutes(); }
From source file:com.metinkale.prayerapp.vakit.times.Times.java
License:Apache License
public int getNext() { LocalDate today = LocalDate.now(); LocalDateTime now = LocalDateTime.now(); for (int i = 0; i < 6; i++) { if (getTimeCal(today, i).isAfter(now)) { return i; }// ww w .jav a 2 s.c o m } return 6; }
From source file:com.metinkale.prayerapp.vakit.WidgetProviderClock2.java
License:Apache License
public static void updateAppWidget(@NonNull Context context, @NonNull AppWidgetManager appWidgetManager, int widgetId) { if (mDP == 0) { Resources r = context.getResources(); mDP = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, r.getDisplayMetrics()); }/* w w w .ja va 2s . co 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); 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); 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(Theme.Light.strokecolor); } 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(Theme.Light.strokecolor); } 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(Theme.Light.strokecolor); } 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")) { Crashlytics.logException(e); } } }
From source file:com.netsteadfast.greenstep.util.SystemExpressionJobUtils.java
License:Apache License
public static List<ExpressionJobObj> getExpressionJobs() throws ServiceException, Exception { int year = Integer.parseInt(SimpleUtils.getStrYMD(SimpleUtils.IS_YEAR)); int month = Integer.parseInt(SimpleUtils.getStrYMD(SimpleUtils.IS_MONTH)); String dayOfWeek = String.valueOf(SimpleUtils.getDayOfWeek(year, month)); String hour = String.valueOf(LocalDateTime.now().getHourOfDay()); String minute = String.valueOf(LocalDateTime.now().getMinuteOfHour()); List<ExpressionJobObj> jobObjList = new ArrayList<ExpressionJobObj>(); @SuppressWarnings("unchecked") ISysExprJobService<SysExprJobVO, TbSysExprJob, String> sysExprJobService = (ISysExprJobService<SysExprJobVO, TbSysExprJob, String>) AppContext .getBean("core.service.SysExprJobService"); Map<String, Object> paramMap = new HashMap<String, Object>(); paramMap.put("system", Constants.getSystem()); paramMap.put("active", YesNo.YES); List<SysExprJobVO> exprJobList = sysExprJobService.findListVOByParams(paramMap); if (null == exprJobList || exprJobList.size() < 1) { return jobObjList; }/* w ww .j a v a2 s . c o m*/ @SuppressWarnings("unchecked") ISysExpressionService<SysExpressionVO, TbSysExpression, String> sysExpressionService = (ISysExpressionService<SysExpressionVO, TbSysExpression, String>) AppContext .getBean("core.service.SysExpressionService"); for (SysExprJobVO exprJob : exprJobList) { if (ExpressionJobConstants.RUNSTATUS_PROCESS_NOW.equals(exprJob.getRunStatus())) { log.warn("[Expression-Job] Please check it, process now, Id: " + exprJob.getExprId() + " , name: " + exprJob.getName()); continue; } if (!isRunTime(exprJob, dayOfWeek, hour, minute)) { continue; } ExpressionJobObj jobObj = new ExpressionJobObj(); jobObj.setSysExprJob(exprJob); jobObj.setSysExprJobLog(new SysExprJobLogVO()); SysExpressionVO expr = new SysExpressionVO(); expr.setExprId(exprJob.getExprId()); DefaultResult<SysExpressionVO> exprResult = sysExpressionService.findByUK(expr); if (exprResult.getValue() == null) { log.error("[Expression-Job] Id: " + exprJob.getExprId() + " , data not found."); log.error(exprResult.getSystemMessage().getValue()); continue; } expr = exprResult.getValue(); jobObj.setSysExpression(expr); jobObjList.add(jobObj); } return jobObjList; }
From source file:com.nkapps.billing.dao.BankStatementDaoImpl.java
@Override public void saveToPayment() throws Exception { List<BankStatement> bsList; Session sessionQuery = getSession(); String q = " SELECT " + " b " + " FROM BankStatement b" + " WHERE b.transferable IN (1,2,3,4) " + " AND b.transfered = 0 " + " AND b.bankStatementPayments IS EMPTY "; Query query = sessionQuery.createQuery(q); bsList = query.list();//from w w w. j a v a 2 s. co m sessionQuery.close(); sessionQuery = getSession(); ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); Validator validator = factory.getValidator(); if (bsList != null) { LocalDateTime dateTime = LocalDateTime.now(); Session sessionTransaction = getSession(); Transaction transaction = sessionTransaction.beginTransaction(); int itr = 0; for (BankStatement bs : bsList) { itr++; try { transferBankStatementToPayment(sessionQuery, sessionTransaction, validator, bs, dateTime); if (itr % 500 == 0) { sessionTransaction.flush(); sessionTransaction.clear(); } } catch (Exception e) { logger.error("Error on payment saving: exception = " + e.getMessage() + ", bank_statement_id: " + bs.getId()); } } transaction.commit(); sessionTransaction.close(); } sessionQuery.close(); }
From source file:com.nkapps.billing.dao.BankStatementDaoImpl.java
@Override public void saveToReportClick() throws Exception { Session sessionQuery = getSession(); String q = " SELECT bs FROM BankStatement bs" + " WHERE bs.transferable = 5 AND (transfered = 0 OR bs.paymentDate > :paymentDate )"; Query query = sessionQuery.createQuery(q); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -300); // update report click for last five days Date paymentDate = cal.getTime(); query.setParameter("paymentDate", paymentDate); List<BankStatement> bsList = query.list(); sessionQuery.close();//from w ww . j a va 2 s. c o m sessionQuery = getSession(); if (bsList != null) { LocalDateTime dateTime = LocalDateTime.now(); Session sessionTransaction = getSession(); Transaction transaction = sessionTransaction.beginTransaction(); for (BankStatement bs : bsList) { try { String operationDateStr = findOperationDate(bs.getPaymentDetails()); Date operationDate = new SimpleDateFormat("dd.MM.yyyy").parse(operationDateStr); query = sessionQuery.createQuery( "SELECT COALESCE(SUM(p.paymentSum),0) FROM Payment p WHERE p.paymentDate = :paymentDate AND p.sourceCode = 3"); query.setParameter("paymentDate", operationDate); BigDecimal clickPaymentSum = (BigDecimal) query.uniqueResult(); query = sessionTransaction .createQuery("SELECT rc FROM ReportClick rc WHERE rc.operationDate = :operationDate"); query.setParameter("operationDate", operationDate); ReportClick rc = (ReportClick) query.uniqueResult(); if (rc == null) { rc = new ReportClick(); rc.setOperationDate(operationDate); rc.setClickPaymentSum(clickPaymentSum); rc.setDateCreated(dateTime); rc.setDateUpdated(dateTime); sessionTransaction.save(rc); ReportClickBankStatement rcbs = new ReportClickBankStatement(); ReportClickBankStatementId rcbsId = new ReportClickBankStatementId(); rcbsId.setBankStatement(bs); rcbsId.setReportClick(rc); rcbs.setId(rcbsId); sessionTransaction.save(rcbs); } else { rc.setClickPaymentSum(clickPaymentSum); rc.setDateUpdated(dateTime); sessionTransaction.update(rc); query = sessionQuery.createQuery( "SELECT rcbs FROM ReportClickBankStatement rcbs JOIN rcbs.id.reportClick rc JOIN rcbs.id.bankStatement bs WHERE rc = :rc AND bs = :bs"); query.setParameter("rc", rc); query.setParameter("bs", bs); ReportClickBankStatement rcbs = (ReportClickBankStatement) query.uniqueResult(); if (rcbs == null) { rcbs = new ReportClickBankStatement(); ReportClickBankStatementId rcbsId = new ReportClickBankStatementId(); rcbsId.setBankStatement(bs); rcbsId.setReportClick(rc); rcbs.setId(rcbsId); sessionTransaction.save(rcbs); } } if (bs.getTransfered() == 0) { bs.setTransfered((short) 3); bs.setDateUpdated(dateTime); sessionTransaction.update(bs); } } catch (Exception e) { logger.error("Error on report click saving: bank_statement_id = " + bs.getId() + ", exception = " + e.getMessage()); } } transaction.commit(); sessionTransaction.close(); } sessionQuery.close(); }