Example usage for java.util Date after

List of usage examples for java.util Date after

Introduction

In this page you can find the example usage for java.util Date after.

Prototype

public boolean after(Date when) 

Source Link

Document

Tests if this date is after the specified date.

Usage

From source file:com.nec.harvest.service.impl.ProfitByShopServiceImpl.java

/** {@inheritDoc} */
@Override// w w w.ja va 2 s .  co m
public Date checkAvailableByOrgCodeAndMothly(String orgCode, Date monthly, Date businessDay,
        boolean nextOrPrevious) throws ServiceException {
    logger.info("Check available next or previous month to aggregate profit by shop.");

    //
    if (StringUtils.isEmpty(orgCode)) {
        throw new IllegalArgumentException("Organization's code must not be null or empty");
    }

    if (monthly == null) {
        throw new IllegalArgumentException("Monthly must not be null");
    }

    if (businessDay == null) {
        throw new IllegalArgumentException("Business day must not be null");
    }

    // for the case processing month is the business one, disable the next
    // month
    String strBusinessMonth = DateFormatUtil.format(businessDay, DateFormat.DATE_WITHOUT_DAY);
    String strProcessingMonth = DateFormatUtil.format(monthly, DateFormat.DATE_WITHOUT_DAY);
    if (nextOrPrevious && strBusinessMonth.equals(strProcessingMonth)) {
        return null;
    }

    Date monthToCheck = nextOrPrevious ? DateUtil.monthsToAdd(monthly, 1)
            : DateUtil.monthsToSubtract(monthly, 1);
    String strMonthly = DateFormatUtil.format(monthToCheck, DateFormat.DATE_WITHOUT_DAY);
    Date tightenMonth = getTightenBusinessDay(businessDay);

    boolean isAvailable = monthToCheck.after(tightenMonth)
            ? actualViewService.checkAvailableByOrgCodeAndMonthly(orgCode, strMonthly)
            : budgetPerformanceService.checkAvailableByOrgCodeAndMonthly(orgCode, strMonthly);
    if (StringUtils.isNotEmpty(strMonthly) && isAvailable) {
        logger.info("Check available next or previous month to aggregate profit by shop have done.");
        //
        return monthToCheck;
    }

    logger.info("Check available next or previous month to aggregate profit by shop have done.");
    //
    return null;
}

From source file:pi.bestdeal.gui.InterfacePrincipale.java

private void Add_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Add_ButtonActionPerformed

    Panel_Ajouter panajout = new Panel_Ajouter();

    Deal deal = new Deal();

    int result = JOptionPane.showConfirmDialog(null, panajout, "Test", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.PLAIN_MESSAGE);

    if (result == JOptionPane.OK_OPTION) {
        deal.setTitreDeal_Deal(panajout.txtTitre.getText());
        Vendeur vendeur = new Vendeur();
        VendeurDAO daov = VendeurDAO.getInstance();

        for (Vendeur a : daov.displayvendeurByNom(String.valueOf(panajout.jList1.getSelectedValue()))) {
            vendeur = a;//from  ww  w.j a  v a2  s . c  om
        }
        if (panajout.jList1.getSelectedValue() == null) {
            vendeur.setIdVendeur(0);
        }

        deal.setDescDeal_Deal(panajout.txtDesc.getText());
        deal.setPrixDeal_Deal(Double.valueOf(panajout.txtPrix.getText()));
        deal.setNbrAchatValidation(Integer.valueOf(panajout.txtValidation.getText()));
        deal.setNbrAchatActuelDeal_Deal(0);
        deal.setNbrAffichage_Deal(0);
        deal.setEtatDeal_Deal("Comming");
        deal.setCategorie_Deal(panajout.ComboCategorie.getSelectedItem().toString());
        deal.setStatutDeal_Deal(false);
        java.util.Date d1 = panajout.jdateDebut.getCalendar().getTime();
        java.sql.Date sqlDate = new java.sql.Date(d1.getTime());
        java.util.Date d2 = panajout.jdateFin.getCalendar().getTime();
        java.sql.Date sqlDate2 = new java.sql.Date(d2.getTime());
        if (d1.after(d2)) {
            JOptionPane.showMessageDialog(null, "les Dates sont non compatibles");
        } else {
            deal.setDateDebutDeal_Deal(sqlDate);
            deal.setDateFinDeal_Deal(sqlDate2);
            deal.setIdVendeur_Deal(vendeur.getIdVendeur());
            DealDAO dealdao = DealDAO.getInstance();

            dealdao.insertDeal(deal);
            Deal dd = dealdao.displayDeal().get((dealdao.displayDeal().size() - 1));
            y = dd.getIdDeal_Deal();
            System.out.println(y);
            if (panajout.fc.getSelectedFiles().length != 0) {
                for (int i = 0; i < panajout.fc.getSelectedFiles().length; i++) {

                    FileInputStream fis = null;
                    try {
                        fis = new FileInputStream(panajout.file[i]);
                    } catch (FileNotFoundException ex) {
                        Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    ImageDeal imgdeal = new ImageDeal();
                    Path path = Paths.get(panajout.file[i].getAbsolutePath());
                    try {
                        imgdeal.setImage(Files.readAllBytes(path));

                    } catch (IOException ex) {
                        Logger.getLogger(InterfacePrincipale.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    imgdeal.setIdDeal(y);

                    ImageDAO im = ImageDAO.getInstance();
                    im.InsertImage(imgdeal);

                }
            }

            JOptionPane.showMessageDialog(null, "Ajout termin");
            DealTableModel mymodel = new DealTableModel(list.displayDeal());
            jTable1.setModel(mymodel);
            jTable1.removeColumn(jTable1.getColumn("ID"));
            jTable1.removeColumn(jTable1.getColumn("Description"));
            jTable1.removeColumn(jTable1.getColumn("Achat Actuel"));
            jTable1.removeColumn(jTable1.getColumn("Etat"));
            jTable1.removeColumn(jTable1.getColumn("Statut"));
            jTable1.removeColumn(jTable1.getColumn("Nombre d'Affichage"));
            jTable1.removeColumn(jTable1.getColumn("Vendeur"));

            jTable1.getColumnModel().setColumnMargin(20);
            jTable1.setRowSelectionInterval(0, 0);
            y = mymodel.getRowCount();
            panajout.w = y;
            System.out.println("la valeur de y est :" + y + "et " + panajout.w);
        }
    } else {
        System.out.println("Cancelled");
    }

}

From source file:com.gestec.modelo.controladores.UserController.java

public void validarFecha(FacesContext context, UIComponent toValidate, Object value) throws ParseException {
    context = FacesContext.getCurrentInstance();
    Date texto = (Date) value;

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date fecha = sdf.parse("2000-01-01");
    ResourceBundle bundle = context.getApplication().getResourceBundle(context, "msjGestec");

    FacesMessage msjGestec = null;//from   w w  w .j a v  a  2  s .  c  o m
    if (texto == null) {
        ((UIInput) toValidate).setValid(false);
        msjGestec = new FacesMessage(bundle.getString("bundle8"));
        context.addMessage(toValidate.getClientId(context), msjGestec);
    } else if (texto.after(fecha)) {
        ((UIInput) toValidate).setValid(false);
        msjGestec = new FacesMessage(bundle.getString("bundle9"));
        context.addMessage(toValidate.getClientId(context), msjGestec);
    }
}

From source file:com.collabnet.ccf.teamforge.TFReader.java

/**
 * Queries the tracker for the artifact with artifactId and returns its
 * latest data encoded in an GenericArtifact object. The TFReader is capable
 * of retrieving the artifact change history. But this feature is turned off
 * as of now./*  w ww  .j av  a 2s .c  o  m*/
 * 
 * @see com.collabnet.ccf.core.AbstractReader#getArtifactData(org.dom4j.Document,
 *      java.lang.String)
 */
@Override
public GenericArtifact getArtifactData(Document syncInfo, String artifactId) {
    String sourceSystemId = this.getSourceSystemId(syncInfo);
    String sourceSystemKind = this.getSourceSystemKind(syncInfo);
    String sourceRepositoryId = this.getSourceRepositoryId(syncInfo);
    String sourceRepositoryKind = this.getSourceRepositoryKind(syncInfo);
    boolean isArtifactForced = this.isArtifactForced(syncInfo);
    Date lastModifiedDate = this.getLastModifiedDate(syncInfo);
    String rmdID = this.getRepositoryMappingDirectionId(syncInfo);
    Date artifactLastModifiedDate = this.getArtifactLastModifiedDate(syncInfo);
    String sourceSystemTimezone = this.getSourceSystemTimezone(syncInfo);
    Connection connection;
    try {
        connection = connect(sourceSystemId, sourceSystemKind, sourceRepositoryId, sourceRepositoryKind,
                serverUrl, getUsername() + TFConnectionFactory.PARAM_DELIMITER + getPassword());
    } catch (MaxConnectionsReachedException e) {
        String cause = "Could not create connection to the TF system. Max connections reached for " + serverUrl;
        log.error(cause, e);
        throw new CCFRuntimeException(cause, e);
    } catch (ConnectionException e) {
        String cause = "Could not create connection to the TF system " + serverUrl;
        log.error(cause, e);
        throw new CCFRuntimeException(cause, e);
    }
    GenericArtifact genericArtifact = null;
    String lastModifiedBy = null;

    boolean isResync = false;
    boolean isIgnore = false;

    try {
        if (TFConnectionFactory.isTrackerRepository(sourceRepositoryId)) {
            TrackerFieldDO[] trackerFields = null;
            HashMap<String, List<TrackerFieldDO>> fieldsMap = null;
            if (this.isIncludeFieldMetaData()) {
                trackerFields = trackerHandler.getFlexFields(connection, sourceRepositoryId);
                fieldsMap = TFAppHandler.loadTrackerFieldsInHashMap(trackerFields);
            }
            ArtifactDO artifact = null;
            if (isPre44SP1HF1System()) {
                artifact = trackerHandler.getTrackerItem(connection, artifactId);
            } else {
                artifact = trackerHandler.getTrackerItemFull(connection, artifactId);
            }
            lastModifiedBy = artifact.getLastModifiedBy();
            Date creationDate = artifact.getCreatedDate();
            if (lastModifiedBy.equalsIgnoreCase(getUsername()) && isIgnoreConnectorUserUpdates()
                    && !isArtifactForced) {
                if (creationDate.after(lastModifiedDate)) {
                    log.info(String.format(
                            "resync is necessary, despite the artifact %s last being updated by the connector user",
                            artifactId));
                    isResync = true;
                } else {
                    log.info(String.format("artifact %s is an ordinary connector update, ignore it.",
                            artifactId));
                    isIgnore = true;
                }
            }

            String planningFolderHumanReadableName = null;
            String reportedInRelaseHumanReadableName = null;
            String resolvedInReleaseHumanReadableName = null;

            if (!isIgnore) {
                // we're interested in the comments.
                if (getIdentityMappingDatabaseReader() != null) {
                    lastModifiedDate = artifactLastModifiedDate;
                }
                TFAppHandler appHandler = new TFAppHandler(connection);
                appHandler.addComments(artifact, lastModifiedDate,
                        isIgnoreConnectorUserUpdates() ? this.getUsername() : "",
                        isIgnoreConnectorUserUpdates() ? this.getResyncUserName() : "",
                        isPreserveBulkCommentOrder());
                if (this.shipReleaseHumanReadableName) {
                    reportedInRelaseHumanReadableName = getHumanReadableReleaseName(connection,
                            artifact.getReportedReleaseId());
                    resolvedInReleaseHumanReadableName = getHumanReadableReleaseName(connection,
                            artifact.getResolvedReleaseId());
                }
                if (this.shipPlanningFolderHumanReadableName && connection.supports53()) {
                    planningFolderHumanReadableName = getHumanReadablePlanningFolderName(connection,
                            artifact.getPlanningFolderId());
                }
                if (this.translateTechnicalReleaseIds) {
                    convertReleaseIds(connection, artifact);
                }
            }
            genericArtifact = TFToGenericArtifactConverter.convertArtifact(connection.supports53(),
                    connection.supports54(), artifact, fieldsMap, lastModifiedDate,
                    this.isIncludeFieldMetaData(), sourceSystemTimezone, reportedInRelaseHumanReadableName,
                    resolvedInReleaseHumanReadableName, planningFolderHumanReadableName);

            // now care about parent artifacts/planning folders
            // first we find out whether we have a parent artifact or not
            // but only if we don't ignore this shipment anyway
            boolean doRetrieveParentInfo = doRetrieveParentTrackerInfo(rmdID);
            if (!isIgnore && doRetrieveParentInfo) {
                ArtifactDependencyRow[] parents = trackerHandler.getArtifactParentDependencies(connection,
                        artifactId);
                if (parents.length == 0) {
                    // we do not have any parent, so maybe we set a planning folder as our parent
                    if (connection.supports53()) {
                        String planningFolderId = artifact.getPlanningFolderId();
                        if (planningFolderId == null) {
                            genericArtifact.setDepParentSourceArtifactId(GenericArtifact.VALUE_NONE);
                        } else {
                            genericArtifact.setDepParentSourceArtifactId(planningFolderId);
                            // we have to set the repository id as well => we have to retrieve the planning folder
                            PlanningFolderDO planningFolder = connection.getPlanningClient()
                                    .getPlanningFolderData(planningFolderId);
                            genericArtifact.setDepParentSourceRepositoryId(
                                    planningFolder.getProjectId() + "-planningFolders");
                        }
                    }
                } else {
                    // only take first entry of this record
                    ArtifactDependencyRow parent = parents[0];
                    String parentId = parent.getOriginId();
                    genericArtifact.setDepParentSourceArtifactId(parentId);
                    ArtifactDO parentArtifact = trackerHandler.getTrackerItem(connection, parentId);
                    genericArtifact.setDepParentSourceRepositoryId(parentArtifact.getFolderId());
                }
            }

        } else {

            // we retrieve planning folder data now
            PlanningFolderDO planningFolder = connection.getPlanningClient().getPlanningFolderData(artifactId);
            lastModifiedBy = planningFolder.getLastModifiedBy();
            Date creationDate = planningFolder.getCreatedDate();
            if (lastModifiedBy.equalsIgnoreCase(getUsername()) && isIgnoreConnectorUserUpdates()) {
                if (creationDate.after(lastModifiedDate)) {
                    log.info(String.format(
                            "resync is necessary, despite the planning folder %s last being updated by the connector user",
                            artifactId));
                    isResync = true;
                } else {
                    log.info(String.format("artifact %s is an ordinary connector update, ignore it.",
                            artifactId));
                    isIgnore = true;
                }
            }

            String releaseHumandReadableName = null;

            if (!isIgnore && connection.supports54()) {
                if (shipReleaseHumanReadableName) {
                    releaseHumandReadableName = getHumanReadableReleaseName(connection,
                            planningFolder.getReleaseId());
                }
                if (isTranslateTechnicalReleaseIds()) {
                    convertReleaseIds(connection, planningFolder);
                }
            }

            genericArtifact = TFToGenericArtifactConverter.convertPlanningFolder(connection, planningFolder,
                    lastModifiedDate, this.isIncludeFieldMetaData(), sourceSystemTimezone,
                    releaseHumandReadableName);

            // finally, we have to set some info about the parent,
            // but only if we don't ignore this shipment anyway
            if (!isIgnore && isRetrieveParentInfoForPlanningFolders()) {
                genericArtifact.setDepParentSourceRepositoryId(sourceRepositoryId);
                if (planningFolder.getParentFolderId().startsWith("PlanningApp")) {
                    genericArtifact.setDepParentSourceArtifactId(GenericArtifact.VALUE_NONE);
                } else {
                    genericArtifact.setDepParentSourceArtifactId(planningFolder.getParentFolderId());
                }
            }

            lastModifiedBy = planningFolder.getLastModifiedBy();
        }
        if (isIgnore) {
            genericArtifact.setArtifactAction(GenericArtifact.ArtifactActionValue.IGNORE);
        } else if (isResync
                || (lastModifiedBy.equals(this.getResyncUserName()) && isIgnoreConnectorUserUpdates())) {
            genericArtifact.setArtifactAction(GenericArtifact.ArtifactActionValue.RESYNC);
        }

        populateSrcAndDest(syncInfo, genericArtifact);

        if (isArtifactForced) {
            genericArtifact.setTransactionId(DUMMY_FORCE_TRANSACTIONID);
        }

    } catch (RemoteException e) {
        String cause = "During the artifact retrieval process from TF, an error occured";
        log.error(cause, e);
        throw new CCFRuntimeException(cause, e);
    } finally {
        this.disconnect(connection);
    }
    return genericArtifact;
}

From source file:net.chaosserver.timelord.swingui.CommonTaskPanel.java

/**
 *  Cycles through all non-hidden tasks and asks to hide any
 *  that do not have data in the last 30 days.
 *//*  w  ww . j a  va 2s . co m*/
public void showHideTaskDialog() {
    List<TimelordTask> timelordTasks = getTimelordData().getTaskCollection();

    Iterator<TimelordTask> timelordTaskIterator = timelordTasks.iterator();

    Calendar oldestDateCalendar = Calendar.getInstance();
    oldestDateCalendar.add(Calendar.MONTH, -1);
    DateUtil.trunc(oldestDateCalendar);
    Date oldestDate = oldestDateCalendar.getTime();

    while (timelordTaskIterator.hasNext()) {
        TimelordTask timelordTask = timelordTaskIterator.next();
        if (!timelordTask.isHidden()) {
            List<TimelordTaskDay> timelordTaskDays = timelordTask.getTaskDayList();

            Iterator<TimelordTaskDay> timelordTaskDayIterator = timelordTaskDays.iterator();

            TASKDAY_LOOP: while (timelordTaskDayIterator.hasNext()) {
                TimelordTaskDay timelordTaskDay = timelordTaskDayIterator.next();

                if (timelordTaskDay.getHours() > 0) {
                    Date lastInputDate = timelordTaskDay.getDate();

                    if (oldestDate.after(lastInputDate)) {
                        int result = showHideTaskDialog(timelordTask.getTaskName(), lastInputDate);

                        if (result == 0) {
                            timelordTask.setHidden(true);
                        }
                    }

                    // After the oldest date has been found, break
                    // out of the date loop.
                    break TASKDAY_LOOP;
                }
            }
        }
    }
}

From source file:ve.gob.mercal.app.controllers.publicadorControlador.java

@RequestMapping(value = { "/magregarPlanificacion" }, method = RequestMethod.POST)
public ModelAndView postmagregarPlanificacion(@RequestParam(value = "fecha", required = false) String fecha,
        @RequestParam(value = "hora", required = false) String hora,
        @RequestParam(value = "nombreTienda", required = false) String tienda) throws ParseException {

    ModelAndView model = getciagregarPlanificacion();
    int result = -999;
    int result2 = -999;
    String id_tienda = "NULL";
    String id_job = "NULL";
    String id_user = "NULL";
    Date fechaact = new Date();
    String fechaparam = fecha + " " + hora;
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date2 = formatter.parse(fechaparam);

    if (date2.after(fechaact)) {
        try {//w  w  w  .ja  va  2s.co  m
            id_tienda = wsQuery.getConsulta(
                    "SELECT id_tienda FROM public.tiendas WHERE tienda='" + tienda + "'and activo=TRUE;");
            id_tienda = id_tienda.substring(1, id_tienda.length() - 1);
            JsonParser parser3 = new JsonParser();
            JsonElement elementObject;
            elementObject = parser3.parse(id_tienda);
            id_tienda = elementObject.getAsJsonObject().get("id_tienda").getAsString();

            id_job = wsQuery.getConsulta(
                    "SELECT id_job FROM public.jobs WHERE job='INICIAR_MEDIACION' and activo=TRUE;");
            id_job = id_job.substring(1, id_job.length() - 1);
            JsonParser parser = new JsonParser();
            JsonElement elementObject2;
            elementObject2 = parser.parse(id_job);
            if (existeCampo.existeCampo(id_job, "id_job")) {
                id_job = elementObject2.getAsJsonObject().get("id_job").getAsString();
            }

            Authentication auth = SecurityContextHolder.getContext().getAuthentication();
            String name = auth.getName(); //get logged in username

            id_user = wsQuery
                    .getConsulta("SELECT id_usuario FROM public.usuarios WHERE usuario='" + name + "';");
            id_user = id_user.substring(1, id_user.length() - 1);
            JsonParser parser2 = new JsonParser();
            JsonElement elementObject1;
            elementObject1 = parser2.parse(id_user);
            id_user = elementObject1.getAsJsonObject().get("id_usuario").getAsString();

            result = WsFuncion.getConsulta("public.insert_plan_ejecuciones_planif(" + id_tienda + "," + id_job
                    + ",'" + fecha + " " + hora + "'," + id_user + ");");
            if (result > 0) {
                result2 = WsFuncion.getConsulta("public.insert_pasos_plan_ejecucion(" + result + ","
                        + "'en espera'" + "," + id_user + ");");
            }

        } catch (ExcepcionServicio ex) {
            Logger.getLogger(publicadorControlador.class.getName()).log(Level.SEVERE, null, ex);
        }

        if (result2 > 0) {
            model.addObject("mensaje", "exito");
        } else {
            model.addObject("mensaje", "error");
        }

    } else {
        model.addObject("mensaje5", "errorfecha");
    }
    model.setViewName("magregarPlanificacion");
    return model;
}

From source file:com.nec.harvest.controller.SuihController.java

/**
 * /*from w w w .  j  a  v a 2  s .c o m*/
 * @param currentQuater
 * @param currentYear
 * @param model
 * @param finalTighten
 * @param orgCodes
 * @param businessDay
 * @return
 */
private boolean availableNext(int currentQuater, Date currentYear, Model model, Date finalTighten,
        List<String> orgCodes, Date businessDay) {
    final String URL_NEXT = "nextUrl";
    String nextQuarter = null;
    try {
        // if quarter equal 4 then set quarter equal 1
        int intNextQuater = currentQuater + 1;
        if (currentQuater == 5) {
            intNextQuater = 1;
        }

        // get three month of next quarter
        String[] monthiesNext = DateUtil.getMonthliesOfQuarter(currentYear, intNextQuater);
        Date firstDate = DateFormatUtil.parse(monthiesNext[0], DateFormat.DATE_WITHOUT_DAY);
        if (firstDate.after(businessDay)) {
            // next url set null <=> disabled button next 
            model.addAttribute(URL_NEXT, nextQuarter);
            return true;
        }
        // greater than tighten date
        if (firstDate.after(finalTighten)) {
            // count data in v_jiseki view if count greater > 0 then return true otherwise return false
            if (actualViewService.checkAvailableByOrgCodesAndMonthlies(orgCodes, monthiesNext)) {
                nextQuarter = DateUtil.nextQuarter(firstDate);
            }
        } else {
            // count data in budget performance if count greater > 0 then return true otherwise return false
            boolean isNextAvailable = budgetPerformanceService.checkAvailableByOrgCodesAndMonthlyAndKmkCodeJs(
                    orgCodes, monthiesNext[0], Constants.DEFAULT_KMKCODEJ_K7111,
                    Constants.DEFAULT_KMKCODEJ_K7521, Constants.DEFAULT_KMKCODEJ_K8110,
                    Constants.DEFAULT_KMKCODEJ_K8210, Constants.DEFAULT_KMKCODEJ_K8310);
            if (isNextAvailable) {
                nextQuarter = DateUtil.nextQuarter(firstDate);
            }
        }
        model.addAttribute(URL_NEXT, nextQuarter);
    } catch (IllegalArgumentException | NullPointerException | ParseException ex) {
        logger.warn(ex.getMessage());

        // next url set null <=> disabled button next
        model.addAttribute(URL_NEXT, nextQuarter);
    } catch (ServiceException ex) {
        logger.error(ex.getMessage(), ex);

        // ???????????
        model.addAttribute(ERROR_MESSAGE, getSystemError());
        model.addAttribute(ERROR, true);
        return false;
    }
    return true;
}

From source file:ve.gob.mercal.app.controllers.publicadorControlador.java

@RequestMapping(value = { "/ciagregarPlanificacion" }, method = RequestMethod.POST)
public ModelAndView postciagregarPlanificacion(@RequestParam(value = "fecha", required = false) String fecha,
        @RequestParam(value = "hora", required = false) String hora,
        @RequestParam(value = "nombreTienda", required = false) String tienda) throws ParseException {

    ModelAndView model = getciagregarPlanificacion();
    int result = -999;
    int result2 = -999;
    String id_tienda = "NULL";
    String id_job = "NULL";
    String id_user = "NULL";
    Date fechaact = new Date();
    String fechaparam = fecha + " " + hora;
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date date2 = formatter.parse(fechaparam);

    if (date2.after(fechaact)) {

        try {/*from  ww  w  .j  av a  2 s  .co  m*/
            id_tienda = wsQuery.getConsulta(
                    "SELECT id_tienda FROM public.tiendas WHERE tienda='" + tienda + "'and activo=TRUE;");
            id_tienda = id_tienda.substring(1, id_tienda.length() - 1);
            JsonParser parser3 = new JsonParser();
            JsonElement elementObject;
            elementObject = parser3.parse(id_tienda);
            if (existeCampo.existeCampo(id_tienda, "id_tienda")) {
                id_tienda = elementObject.getAsJsonObject().get("id_tienda").getAsString();
            }

            id_job = wsQuery
                    .getConsulta("SELECT id_job FROM public.jobs WHERE job='INICIAR_CARGA' and activo=TRUE;");
            id_job = id_job.substring(1, id_job.length() - 1);
            JsonParser parser = new JsonParser();
            JsonElement elementObject2;
            elementObject2 = parser.parse(id_job);
            if (existeCampo.existeCampo(id_job, "id_job")) {
                id_job = elementObject2.getAsJsonObject().get("id_job").getAsString();
            }

            Authentication auth = SecurityContextHolder.getContext().getAuthentication();
            String name = auth.getName(); //get logged in username

            id_user = wsQuery
                    .getConsulta("SELECT id_usuario FROM public.usuarios WHERE usuario='" + name + "';");
            id_user = id_user.substring(1, id_user.length() - 1);
            JsonParser parser2 = new JsonParser();
            JsonElement elementObject1;
            elementObject1 = parser2.parse(id_user);
            id_user = elementObject1.getAsJsonObject().get("id_usuario").getAsString();

            result = WsFuncion.getConsulta("public.insert_plan_ejecuciones_planif(" + id_tienda + "," + id_job
                    + ",'" + fecha + " " + hora + "'," + id_user + ");");
            if (result > 0) {
                result2 = WsFuncion.getConsulta("public.insert_pasos_plan_ejecucion(" + result + ","
                        + "'en espera'" + "," + id_user + ");");
            }

        } catch (ExcepcionServicio ex) {
            Logger.getLogger(publicadorControlador.class.getName()).log(Level.SEVERE, null, ex);
        }

        if (result2 > 0) {
            model.addObject("mensaje", "exito");
        } else {
            model.addObject("mensaje", "error");
        }

    } else {
        model.addObject("mensaje5", "errorfecha");
    }
    model.setViewName("ciagregarPlanificacion");
    return model;

}