List of usage examples for org.joda.time Days daysBetween
public static Days daysBetween(ReadablePartial start, ReadablePartial end)
Days
representing the number of whole days between the two specified partial datetimes. From source file:com.softtek.mdm.service.impl.LicenseServiceImpl.java
License:Open Source License
private Integer getTimeDifference(String time) { SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd"); String endTime = time;// w ww . j a v a 2s.c o m String nowDate = date.format(new Date()); Date now = null; Date end = null; try { now = date.parse(nowDate); end = date.parse(endTime); } catch (ParseException e) { e.getMessage(); return -1; } return Days.daysBetween(new DateTime(now), new DateTime(end)).getDays(); }
From source file:com.sojanddesign.boxes.domain.model.user.User.java
License:Open Source License
/** * Active the current user and initialize default boxes for him. * @throws ExpirationActivationUserException if creation date is greater than {@code NB_ACTIVATION_DAY_MAX} *//*w ww. j ava 2s. c om*/ public void activate() throws DomainException { int nbDay = Days.daysBetween(new DateTime(this.accountSettings.getCreationDate()), Instant.now()).getDays(); if (nbDay > NB_ACTIVATION_DAY_MAX) { active = false; throw new ExpirationActivationUserException("The activation request has exceeded the period of " + NB_ACTIVATION_DAY_MAX + " days for " + accountSettings.getEmail()); } intializeDefaultBoxes(); active = true; }
From source file:com.sonicle.webtop.calendar.CalendarManager.java
License:Open Source License
public List<LocalDate> listEventDates(Collection<Integer> calendarIds, DateTime from, DateTime to, DateTimeZone refTimezone) throws WTException { EventDAO evtDao = EventDAO.getInstance(); Connection con = null;/* w w w.ja v a 2 s. c om*/ try { con = WT.getConnection(SERVICE_ID); List<Integer> okCalendarIds = calendarIds.stream() .filter(calendarId -> quietlyCheckRightsOnCalendarFolder(calendarId, "READ")) .collect(Collectors.toList()); HashSet<LocalDate> dates = new HashSet<>(); for (VVEvent vevt : evtDao.viewByCalendarRangeCondition(con, okCalendarIds, from, to, null)) { dates.addAll(CalendarUtils.getDatesSpan(vevt.getAllDay(), vevt.getStartDate(), vevt.getEndDate(), DateTimeZone.forID(vevt.getTimezone()))); } int noOfRecurringInst = Days.daysBetween(from, to).getDays() + 2; for (VVEvent vevt : evtDao.viewRecurringByCalendarRangeCondition(con, okCalendarIds, from, to, null)) { final List<SchedEventInstance> instances = calculateRecurringInstances(con, new SchedEventInstanceMapper(vevt), from, to, refTimezone, noOfRecurringInst); for (SchedEventInstance instance : instances) { dates.addAll(CalendarUtils.getDatesSpan(instance.getAllDay(), instance.getStartDate(), instance.getEndDate(), instance.getDateTimeZone())); } } return new ArrayList<>(dates); } catch (SQLException | DAOException ex) { throw wrapException(ex); } finally { DbUtils.closeQuietly(con); } }
From source file:com.sonicle.webtop.calendar.CalendarManager.java
License:Open Source License
@Override public List<SchedEventInstance> listEventInstances(Collection<Integer> calendarIds, DateTimeRange range, Condition<EventQuery> conditionPredicate, DateTimeZone targetTimezone, boolean sort) throws WTException { EventDAO evtDao = EventDAO.getInstance(); Connection con = null;//from www . j a v a 2s . c o m try { List<Integer> okCalendarIds = calendarIds.stream() .filter(calendarId -> quietlyCheckRightsOnCalendarFolder(calendarId, "READ")) .collect(Collectors.toList()); EventPredicateVisitor epv = new EventPredicateVisitor(true, EventPredicateVisitor.Target.NORMAL); org.jooq.Condition norCondition = null; org.jooq.Condition recCondition = null; if (conditionPredicate != null) { norCondition = BaseDAO.createCondition(conditionPredicate, epv); recCondition = BaseDAO.createCondition(conditionPredicate, new EventPredicateVisitor(true, EventPredicateVisitor.Target.RECURRING)); } boolean hasRange = (range != null); DateTime from = hasRange ? range.from : null; DateTime to = hasRange ? range.to : null; DateTime instFrom = epv.hasFromRange() ? epv.getFromRange() : from; DateTime instTo = epv.hasToRange() ? epv.getToRange() : to; int noOfRecurringInst = hasRange ? Days.daysBetween(from, to).getDays() + 2 : 368; con = WT.getConnection(SERVICE_ID); ArrayList<SchedEventInstance> instances = new ArrayList<>(); for (VVEvent vevt : evtDao.viewByCalendarRangeCondition(con, okCalendarIds, from, to, norCondition)) { SchedEventInstance item = ManagerUtils.fillSchedEvent(new SchedEventInstance(), vevt); item.setKey(EventKey.buildKey(vevt.getEventId(), vevt.getSeriesEventId())); instances.add(item); } for (VVEvent vevt : evtDao.viewRecurringByCalendarRangeCondition(con, okCalendarIds, from, to, recCondition)) { instances.addAll(calculateRecurringInstances(con, new SchedEventInstanceMapper(vevt), instFrom, instTo, targetTimezone, noOfRecurringInst)); } //TODO: transform to an ordered insert if (sort) { Collections.sort(instances, new Comparator<SchedEventInstance>() { @Override public int compare(final SchedEventInstance se1, final SchedEventInstance se2) { return se1.getStartDate().compareTo(se2.getStartDate()); } }); } return instances; } catch (SQLException | DAOException ex) { throw wrapException(ex); } finally { DbUtils.closeQuietly(con); } }
From source file:com.sonicle.webtop.calendar.rpt.AbstractAgenda.java
License:Open Source License
public void setDataSource(CalendarManager manager, DateTime fromDate, DateTime toDate, DateTimeZone utz, Map<Integer, Calendar> calendars, Collection<SchedEventInstance> instances) throws WTException { int days = -1; if (DateTimeUtils.isEndOfDay(toDate, true)) { days = Days.daysBetween(fromDate, toDate).getDays() + 1; } else if (DateTimeUtils.isMidnight(toDate)) { days = Days.daysBetween(fromDate, toDate).getDays(); }// www.ja v a2 s . co m DateTime dayDateFrom = null; ArrayList<Date> dayDates = new ArrayList<>(); ArrayList<ArrayList<RBAgendaEvent>> daysSpanningEvents = new ArrayList<>(); ArrayList<ArrayList<RBAgendaEvent>> daysEvents = new ArrayList<>(); // Prepare structures... for (int i = 0; i < days; i++) { dayDateFrom = fromDate.plusDays(i); dayDates.add(dayDateFrom.toDate()); daysSpanningEvents.add(new ArrayList<RBAgendaEvent>()); daysEvents.add(new ArrayList<RBAgendaEvent>()); } // Arranges events by day... for (SchedEventInstance sei : instances) { for (int i = 0; i < days; i++) { dayDateFrom = fromDate.plusDays(i); if (isInDay(utz, dayDateFrom, sei.getStartDate(), sei.getEndDate())) { Calendar calendar = calendars.get(sei.getCalendarId()); boolean spanning = true; Integer spanLeft = null, spanRight = null; if (!sei.getAllDay() && startsInDay(utz, dayDateFrom, sei.getStartDate()) && endsInDay(utz, dayDateFrom, sei.getEndDate())) { spanning = false; } else { if (startsInDay(utz, dayDateFrom, sei.getStartDate())) { spanRight = DateTimeUtils.datesBetween(dayDateFrom, sei.getEndDate().withZone(utz)); } if (endsInDay(utz, dayDateFrom, sei.getEndDate())) { spanLeft = DateTimeUtils.datesBetween(sei.getStartDate().withZone(utz), dayDateFrom); } if (!startsInDay(utz, dayDateFrom, sei.getStartDate()) && !endsInDay(utz, dayDateFrom, sei.getEndDate())) { spanLeft = DateTimeUtils.datesBetween(sei.getStartDate().withZone(utz), dayDateFrom); spanRight = DateTimeUtils.datesBetween(dayDateFrom, sei.getEndDate().withZone(utz)); } } if (spanning) { daysSpanningEvents.get(i).add(new RBAgendaEvent(calendar, sei, spanLeft, spanRight)); } else { daysEvents.get(i).add(new RBAgendaEvent(calendar, sei, spanLeft, spanRight)); } } } } setDataSource(createBeanCollection(new Data(utz, fromDate.toLocalDate(), toDate.minusDays(1).toLocalDate(), dayDates, daysSpanningEvents, daysEvents))); }
From source file:com.splicemachine.db.iapi.types.SQLDate.java
License:Apache License
@Override public NumberDataValue minus(DateTimeDataValue leftOperand, DateTimeDataValue rightOperand, NumberDataValue returnValue) throws StandardException { if (returnValue == null) returnValue = new SQLInteger(); if (leftOperand.isNull() || isNull() || rightOperand.isNull()) { returnValue.restoreToNull();/*from w w w. j a v a 2 s. c o m*/ return returnValue; } DateTime thatDate = rightOperand.getDateTime(); Days diff = Days.daysBetween(thatDate, leftOperand.getDateTime()); returnValue.setValue(diff.getDays()); return returnValue; }
From source file:com.splicemachine.db.iapi.types.SQLTimestamp.java
License:Apache License
@Override public NumberDataValue minus(DateTimeDataValue leftOperand, DateTimeDataValue rightOperand, NumberDataValue resultHolder) throws StandardException { if (resultHolder == null) resultHolder = new SQLInteger(); if (leftOperand.isNull() || isNull() || rightOperand.isNull()) { resultHolder.restoreToNull();/*from w w w. java2 s .c om*/ return resultHolder; } DateTime thatDate = rightOperand.getDateTime(); Days diff = Days.daysBetween(thatDate, leftOperand.getDateTime()); resultHolder.setValue(diff.getDays()); return resultHolder; }
From source file:com.squid.kraken.v4.api.core.EngineUtils.java
License:Open Source License
/** * Convert the facet value into a date. * If the value start with '=', it is expected to be a Expression, in which case we'll try to resolve it to a Date constant. * @param ctx// w w w .ja va2 s.c o m * @param index * @param lower * @param value * @param compareFromInterval * @return * @throws ParseException * @throws ScopeException * @throws ComputingException */ public Date convertToDate(Universe universe, DimensionIndex index, Bound bound, String value, IntervalleObject compareFromInterval) throws ParseException, ScopeException, ComputingException { if (value.equals("")) { return null; } else if (value.startsWith("__")) { // // support hard-coded shortcuts if (value.toUpperCase().startsWith("__COMPARE_TO_")) { // for compareTo if (compareFromInterval == null) { // invalid compare_to selection... return null; } if (value.equalsIgnoreCase("__COMPARE_TO_PREVIOUS_PERIOD")) { LocalDate localLower = new LocalDate(((Date) compareFromInterval.getLowerBound()).getTime()); if (bound == Bound.UPPER) { LocalDate date = localLower.minusDays(1); return date.toDate(); } else { LocalDate localUpper = new LocalDate( ((Date) compareFromInterval.getUpperBound()).getTime()); Days days = Days.daysBetween(localLower, localUpper); LocalDate date = localLower.minusDays(1 + days.getDays()); return date.toDate(); } } if (value.equalsIgnoreCase("__COMPARE_TO_PREVIOUS_MONTH")) { LocalDate localLower = new LocalDate(((Date) compareFromInterval.getLowerBound()).getTime()); LocalDate compareLower = localLower.minusMonths(1); if (bound == Bound.LOWER) { return compareLower.toDate(); } else { LocalDate localUpper = new LocalDate( ((Date) compareFromInterval.getUpperBound()).getTime()); Days days = Days.daysBetween(localLower, localUpper); LocalDate compareUpper = compareLower.plusDays(days.getDays()); return compareUpper.toDate(); } } if (value.equalsIgnoreCase("__COMPARE_TO_PREVIOUS_YEAR")) { LocalDate localLower = new LocalDate(((Date) compareFromInterval.getLowerBound()).getTime()); LocalDate compareLower = localLower.minusYears(1); if (bound == Bound.LOWER) { return compareLower.toDate(); } else { LocalDate localUpper = new LocalDate( ((Date) compareFromInterval.getUpperBound()).getTime()); Days days = Days.daysBetween(localLower, localUpper); LocalDate compareUpper = compareLower.plusDays(days.getDays()); return compareUpper.toDate(); } } } else { // for regular // get MIN, MAX first Intervalle range = null; if (index.getDimension().getType() == Type.CONTINUOUS) { if (index.getStatus() == Status.DONE) { List<DimensionMember> members = index.getMembers(); if (!members.isEmpty()) { DimensionMember member = members.get(0); Object object = member.getID(); if (object instanceof Intervalle) { range = (Intervalle) object; } } } else { try { DomainHierarchy hierarchy = universe .getDomainHierarchy(index.getAxis().getParent().getDomain()); hierarchy.isDone(index, null); } catch (ComputingException | InterruptedException | ExecutionException | TimeoutException e) { throw new ComputingException("failed to retrieve period interval"); } } } if (range == null) { range = IntervalleObject.createInterval(new Date(), new Date()); } if (value.equalsIgnoreCase("__ALL")) { if (index.getDimension().getType() != Type.CONTINUOUS) { return null; } if (bound == Bound.UPPER) { return (Date) range.getUpperBound(); } else { return (Date) range.getLowerBound(); } } if (value.equalsIgnoreCase("__LAST_DAY")) { if (bound == Bound.UPPER) { return (Date) range.getUpperBound(); } else { return (Date) range.getUpperBound(); } } if (value.equalsIgnoreCase("__LAST_7_DAYS")) { if (bound == Bound.UPPER) { return (Date) range.getUpperBound(); } else { LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime()); LocalDate date = localUpper.minusDays(6);// 6+1 return date.toDate(); } } if (value.equalsIgnoreCase("__CURRENT_MONTH")) { if (bound == Bound.UPPER) { return (Date) range.getUpperBound(); } else { LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime()); LocalDate date = localUpper.withDayOfMonth(1); return date.toDate(); } } if (value.equalsIgnoreCase("__CURRENT_YEAR")) { if (bound == Bound.UPPER) { return (Date) range.getUpperBound(); } else { LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime()); LocalDate date = localUpper.withMonthOfYear(1).withDayOfMonth(1); return date.toDate(); } } if (value.equalsIgnoreCase("__PREVIOUS_MONTH")) {// the previous complete month if (bound == Bound.UPPER) { LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime()); LocalDate date = localUpper.withDayOfMonth(1).minusDays(1); return date.toDate(); } else { LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime()); LocalDate date = localUpper.withDayOfMonth(1).minusMonths(1); return date.toDate(); } } if (value.equalsIgnoreCase("__PREVIOUS_YEAR")) {// the previous complete month if (bound == Bound.UPPER) { LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime()); LocalDate date = localUpper.withMonthOfYear(1).withDayOfMonth(1).minusDays(1); return date.toDate(); } else { LocalDate localUpper = new LocalDate(((Date) range.getUpperBound()).getTime()); LocalDate date = localUpper.withMonthOfYear(1).withDayOfMonth(1).minusYears(1); return date.toDate(); } } } throw new ScopeException("undefined facet expression alias: " + value); } else if (value.startsWith("=")) { // if the value starts by equal token, this is a formula that can be // evaluated try { String expr = value.substring(1); // check if the index content is available or wait for it DomainHierarchy hierarchy = universe.getDomainHierarchy(index.getAxis().getParent().getDomain(), true); hierarchy.isDone(index, null); // evaluate the expression Object defaultValue = evaluateExpression(universe, index, expr, compareFromInterval); // check we can use it if (defaultValue == null) { //throw new ScopeException("unable to parse the facet expression as a constant: " + expr); // T1769: it's ok to return null return null; } if (!(defaultValue instanceof Date)) { throw new ScopeException("unable to parse the facet expression as a date: " + expr); } // ok, it's a date return (Date) defaultValue; } catch (ComputingException | InterruptedException | ExecutionException | TimeoutException e) { throw new ComputingException("failed to retrieve period interval"); } } else { Date date = ServiceUtils.getInstance().toDate(value); if (bound == Bound.UPPER && !index.getAxis().getDefinitionSafe().getImageDomain().isInstanceOf(IDomain.TIME)) { // clear the timestamp return new LocalDate(date.getTime()).toDate(); } else { return date; } } }
From source file:com.sreekanth.duelist.F2Activity.java
License:Apache License
public void onClick(View v) { // TODO Auto-generated method stub switch ((v.getId())) { case R.id.button6: Intent agintent = new Intent(F2Activity.this, welcome.class); startActivity(agintent);//from w ww . j a va 2 s. co m break; case R.id.button1: DataViewerSQLiteHelper stockSQLHelper = new DataViewerSQLiteHelper(this); SQLiteDatabase database = stockSQLHelper.getReadableDatabase(); int numRows = (int) DatabaseUtils.longForQuery(database, "SELECT COUNT(*) FROM bmpolmast", null); Toast.makeText(this.getBaseContext(), "No.of Records :: " + numRows, Toast.LENGTH_SHORT).show(); database.close(); stockSQLHelper.close(); Intent intent = new Intent(this, PmActivity.class); startActivity(intent); break; // case R.id.button10: // Intent intent1=new Intent(this,MainActivitynb.class); // startActivity(intent1); // break; case R.id.button2: Intent intentd = new Intent(this, MainActivity.class); startActivity(intentd); break; case R.id.button4: Intent intenta = new Intent(this, AlphabetListDemo.class); startActivity(intenta); break; case R.id.button5: Intent intent3 = new Intent(this, GridViewActivity.class); startActivity(intent3); break; case R.id.button12: DataViewerSQLiteHelper stockSQLHelper1 = new DataViewerSQLiteHelper(this); SQLiteDatabase database1 = stockSQLHelper1.getReadableDatabase(); String sql = ""; sql = "SELECT * FROM registration"; Cursor a = database1.rawQuery(sql, null); a.moveToFirst(); String PPwd = a.getString(a.getColumnIndex("regcouponno")).trim(); String PUser = a.getString(a.getColumnIndex("regagcode")).trim(); a.close(); database1.close(); stockSQLHelper1.close(); String ipadd = "abcd"; d.start(); if (exportDatabase()) { Toast.makeText(F2Activity.this, "Export OVer", Toast.LENGTH_LONG).show(); } ; new taskPols().execute(ipadd, PUser); break; case R.id.button11: d2.start(); final DataViewerSQLiteHelper stockSQLHelpera = new DataViewerSQLiteHelper(F2Activity.this); final SQLiteDatabase databasea = stockSQLHelpera.getReadableDatabase(); String sqla = ""; sqla = "select regagcode from registration"; Cursor aa = databasea.rawQuery(sqla, null); aa.moveToFirst(); // database.delete("agentdata", null, null); String ipadda = aa.getString(aa.getColumnIndex("regagcode")).trim(); databasea.close(); aa.close(); stockSQLHelpera.close(); new taskAg().execute(ipadda); break; case R.id.button13: d1.start(); DataViewerSQLiteHelper stockSQLHelper2 = new DataViewerSQLiteHelper(this); SQLiteDatabase database2 = stockSQLHelper2.getWritableDatabase(); String sql1 = ""; database2.delete(bmbillmast.TABLE_STOCK, null, null); sql1 = "SELECT * FROM bmpolmast where status = '" + "inforce" + "'"; Cursor a1 = database2.rawQuery(sql1, null); for (a1.moveToFirst(); !a1.isAfterLast(); a1.moveToNext()) { ContentValues values1 = new ContentValues(); String duepolicyno = a1.getString(a1.getColumnIndexOrThrow("policyno")); String duepremium = a1.getString(a1.getColumnIndexOrThrow("prem")); String duemode = a1.getString(a1.getColumnIndexOrThrow("mode")); String duedate = a1.getString(a1.getColumnIndexOrThrow("doc")); String duefup = a1.getString(a1.getColumnIndexOrThrow("fup")); String duepolname = a1.getString(a1.getColumnIndexOrThrow("polname")); String dueadd1 = a1.getString(a1.getColumnIndexOrThrow("add1")); String dueadd2 = a1.getString(a1.getColumnIndexOrThrow("add2")); String dueadd3 = a1.getString(a1.getColumnIndexOrThrow("add3")); String duepin = a1.getString(a1.getColumnIndexOrThrow("pin")); String duemobile = a1.getString(a1.getColumnIndexOrThrow("mobile")); String dueagcode = a1.getString(a1.getColumnIndexOrThrow("agcode")); values1.put(bmbillmast.BM_POLNO, duepolicyno); values1.put(bmbillmast.BM_DOC, duedate); values1.put(bmbillmast.BM_MOD, duemode); values1.put(bmbillmast.BM_PREM, duepremium); values1.put(bmbillmast.BM_DUEFROM, duefup); values1.put(bmbillmast.BM_NAME, duepolname); values1.put(bmbillmast.BM_ADD1, dueadd1); values1.put(bmbillmast.BM_ADD2, dueadd2); values1.put(bmbillmast.BM_ADD3, dueadd3); values1.put(bmbillmast.BM_PIN, duepin); values1.put(bmbillmast.BM_MOBILE, duemobile); values1.put(bmbillmast.BM_AGCODE, dueagcode); String dtStart = duedate; SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd"); try { date = format.parse(dtStart); System.out.println(date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); Date date1 = date; datetime = dateformat.format(date1); datetimedd = datetime.substring(0, 2); datetimetoday = dateformat.format(new Date()); System.out.println("Current Date Time : " + datetime); FUP1 = datetimedd + "/" + duefup + " 00:00:00"; SimpleDateFormat format1 = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); try { FUP1cdate = new DateTime(format1.parse(FUP1)); } catch (java.text.ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } DateTime test = new DateTime(); String no_of_days = String.valueOf(Days.daysBetween(FUP1cdate, test).getDays()); if (duemode.equals("Y")) { mode_days = 365; } else if (duemode.equals("H")) { mode_days = 180; } else if (duemode.equals("Q")) { mode_days = 90; } else if (duemode.equals("M")) { mode_days = 30; } // System.out.println(Integer.parseInt(no_of_days)); no_of_inst = (Integer.parseInt(no_of_days) / (mode_days)) + 1; values1.put("nfdues", no_of_inst); String duemonth = duedate.substring(5, 7).trim(); System.out.println(duemonth); if (duemonth.equals("01")) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth.equals("02")) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth.equals("03")) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth.equals("04")) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth.equals("05")) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth.equals("06")) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth.equals("07")) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth.equals("08")) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth.equals("09")) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth.equals("10")) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth.equals("11")) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth.equals("12")) { values1.put(bmbillmast.BM_DECE, "Y"); } if (duemode.equals("H")) { int duemonth1 = Integer.parseInt((duemonth)); duemonth1 = duemonth1 + 6; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } } if (duemode.equals("Q")) { int duemonth1 = Integer.parseInt((duemonth)); duemonth1 = duemonth1 + 3; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } duemonth1 = duemonth1 + 3; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } duemonth1 = duemonth1 + 3; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } } if (duemode.equals("M")) { int duemonth1 = Integer.parseInt((duemonth)); duemonth1 = duemonth1 + 1; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } duemonth1 = duemonth1 + 1; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } duemonth1 = duemonth1 + 1; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } duemonth1 = duemonth1 + 1; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } duemonth1 = duemonth1 + 1; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } duemonth1 = duemonth1 + 1; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } duemonth1 = duemonth1 + 1; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } duemonth1 = duemonth1 + 1; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } duemonth1 = duemonth1 + 1; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } duemonth1 = duemonth1 + 1; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } duemonth1 = duemonth1 + 1; if (duemonth1 > 12) { duemonth1 = duemonth1 - 12; } if (duemonth1 == 1) { values1.put(bmbillmast.BM_JAN, "Y"); } if (duemonth1 == 2) { values1.put(bmbillmast.BM_FEB, "Y"); } if (duemonth1 == 3) { values1.put(bmbillmast.BM_MAR, "Y"); } if (duemonth1 == 4) { values1.put(bmbillmast.BM_APR, "Y"); } if (duemonth1 == 5) { values1.put(bmbillmast.BM_MAY, "Y"); } if (duemonth1 == 6) { values1.put(bmbillmast.BM_JUN, "Y"); } if (duemonth1 == 7) { values1.put(bmbillmast.BM_JUL, "Y"); } if (duemonth1 == 8) { values1.put(bmbillmast.BM_AUG, "Y"); } if (duemonth1 == 9) { values1.put(bmbillmast.BM_SEP, "Y"); } if (duemonth1 == 10) { values1.put(bmbillmast.BM_OCT, "Y"); } if (duemonth1 == 11) { values1.put(bmbillmast.BM_NOV, "Y"); } if (duemonth1 == 12) { values1.put(bmbillmast.BM_DECE, "Y"); } } database2.insert(bmbillmast.TABLE_STOCK, null, values1); } database2.close(); stockSQLHelper2.close(); d1.stop(); break; } }
From source file:com.stackframe.sarariman.DateUtils.java
License:GNU General Public License
public static int daysBetween(Date start, Date end) { DateTime x = new DateTime(start); DateTime y = new DateTime(end); return Days.daysBetween(x, y).getDays(); }