Example usage for java.text SimpleDateFormat setLenient

List of usage examples for java.text SimpleDateFormat setLenient

Introduction

In this page you can find the example usage for java.text SimpleDateFormat setLenient.

Prototype

public void setLenient(boolean lenient) 

Source Link

Document

Specify whether or not date/time parsing is to be lenient.

Usage

From source file:org.apache.click.extras.control.DateField.java

/**
 * Validate the DateField request submission.
 * <p/>/*from   w w w  .j a v  a 2s .co m*/
 * A field error message is displayed if a validation error occurs.
 * These messages are defined in the resource bundle:
 * <blockquote>
 * <ul>
 *   <li>/click-control.properties
 *     <ul>
 *       <li>field-required-error</li>
 *     </ul>
 *   </li>
 *   <li>/org/apache/click/extras/control/DateField.properties
 *     <ul>
 *       <li>date-format-error</li>
 *     </ul>
 *   </li>
 * </ul>
 * </blockquote>
 */
@Override
public void validate() {
    String formatPattern = getFormatPattern();

    if (formatPattern == null) {
        String msg = "dateFormat attribute is null for field: " + getName();
        throw new IllegalStateException(msg);
    }

    super.validate();

    if (isValid() && getValue().length() > 0) {
        SimpleDateFormat dateFormat = getDateFormat();
        dateFormat.setLenient(false);

        try {
            dateFormat.parse(getValue()).getTime();

        } catch (ParseException pe) {
            Object[] args = new Object[] { getErrorLabel(), formatPattern };
            setError(getMessage("date-format-error", args));
        }
    }
}

From source file:net.oddsoftware.android.feedscribe.data.FeedManager.java

public static Date parseRFC3339Date(String datestring) throws ParseException {
    Date d = new Date();

    //if there is no time zone, we don't need to do any special parsing.
    if (datestring.endsWith("Z")) {
        try {//from w  w w  . ja  v a 2 s .c o m
            SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);//spec for RFC3339                    
            d = s.parse(datestring);
        } catch (ParseException pe) {
            //try again with optional decimals
            SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'", Locale.US);//spec for RFC3339 (with fractional seconds)
            s.setLenient(true);
            d = s.parse(datestring);
        }
        return d;
    }

    //step one, split off the timezone.
    int zoneMarker = Math.max(datestring.lastIndexOf('-'), datestring.lastIndexOf('+'));
    String firstpart = datestring.substring(0, zoneMarker);
    String secondpart = datestring.substring(zoneMarker);

    //step two, remove the colon from the timezone offset
    secondpart = secondpart.substring(0, secondpart.indexOf(':'))
            + secondpart.substring(secondpart.indexOf(':') + 1);
    datestring = firstpart + secondpart;
    SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US);//spec for RFC3339      
    try {
        d = s.parse(datestring);
    } catch (java.text.ParseException pe) {
        //try again with optional decimals
        s = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ", Locale.US);//spec for RFC3339 (with fractional seconds)
        s.setLenient(true);
        d = s.parse(datestring);
    }
    return d;
}

From source file:org.finra.dm.service.helper.DmHelper.java

/**
 * Gets a date in a date format from a string format or null if one wasn't specified. The format of the date should match
 * DmDao.DEFAULT_SINGLE_DAY_DATE_MASK./*from   w  w w .j a v  a2  s. c om*/
 *
 * @param dateString the date as a string.
 *
 * @return the date as a date or null if one wasn't specified
 * @throws IllegalArgumentException if the date isn't the correct length or isn't in the correct format
 */
public Date getDateFromString(String dateString) throws IllegalArgumentException {
    String dateStringLocal = dateString;

    // Default the return port value to null.
    Date resultDate = null;

    if (StringUtils.isNotBlank(dateStringLocal)) {
        // Trim the date string.
        dateStringLocal = dateStringLocal.trim();

        // Verify that the date string has the required length.
        Assert.isTrue(dateStringLocal.length() == DmDao.DEFAULT_SINGLE_DAY_DATE_MASK.length(),
                String.format("A date value \"%s\" must contain %d characters and be in \"%s\" format.",
                        dateStringLocal, DmDao.DEFAULT_SINGLE_DAY_DATE_MASK.length(),
                        DmDao.DEFAULT_SINGLE_DAY_DATE_MASK.toUpperCase()));

        // Convert the date from a String to a Date.
        try {
            // Use strict parsing to ensure our date is more definitive.
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DmDao.DEFAULT_SINGLE_DAY_DATE_MASK,
                    Locale.US);
            simpleDateFormat.setLenient(false);
            resultDate = simpleDateFormat.parse(dateStringLocal);
        } catch (Exception ex) {
            throw new IllegalArgumentException(String.format("A date value \"%s\" must be in \"%s\" format.",
                    dateStringLocal, DmDao.DEFAULT_SINGLE_DAY_DATE_MASK.toUpperCase()), ex);
        }
    }

    return resultDate;
}

From source file:org.finra.herd.service.helper.HerdHelper.java

/**
 * Gets a date in a date format from a string format or null if one wasn't specified. The format of the date should match
 * HerdDao.DEFAULT_SINGLE_DAY_DATE_MASK.
 *
 * @param dateString the date as a string.
 *
 * @return the date as a date or null if one wasn't specified
 * @throws IllegalArgumentException if the date isn't the correct length or isn't in the correct format
 *//*from  w  ww  .j  a v a 2  s .c o  m*/
public Date getDateFromString(String dateString) throws IllegalArgumentException {
    String dateStringLocal = dateString;

    // Default the return port value to null.
    Date resultDate = null;

    if (StringUtils.isNotBlank(dateStringLocal)) {
        // Trim the date string.
        dateStringLocal = dateStringLocal.trim();

        // Verify that the date string has the required length.
        Assert.isTrue(dateStringLocal.length() == HerdDao.DEFAULT_SINGLE_DAY_DATE_MASK.length(),
                String.format("A date value \"%s\" must contain %d characters and be in \"%s\" format.",
                        dateStringLocal, HerdDao.DEFAULT_SINGLE_DAY_DATE_MASK.length(),
                        HerdDao.DEFAULT_SINGLE_DAY_DATE_MASK.toUpperCase()));

        // Convert the date from a String to a Date.
        try {
            // Use strict parsing to ensure our date is more definitive.
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(HerdDao.DEFAULT_SINGLE_DAY_DATE_MASK,
                    Locale.US);
            simpleDateFormat.setLenient(false);
            resultDate = simpleDateFormat.parse(dateStringLocal);
        } catch (Exception ex) {
            throw new IllegalArgumentException(String.format("A date value \"%s\" must be in \"%s\" format.",
                    dateStringLocal, HerdDao.DEFAULT_SINGLE_DAY_DATE_MASK.toUpperCase()), ex);
        }
    }

    return resultDate;
}

From source file:com.svi.uzabase.logic.ValidationProcess.java

private List<XMLHolder> validateData(List<XMLHolder> xmlBatchHolder) {
    try {//w ww  .ja v  a2  s.  c om
        int totalCounter = 0;
        //Initialize dictionary
        String dictFileName = "file://./dic/english.jar";
        String configFile = "file://./classes/spellCheck.config";
        BasicDictionary dictionary = new BasicDictionary(dictFileName);
        SpellCheckConfiguration configuration = new SpellCheckConfiguration(configFile);
        BasicSuggester suggester = new BasicSuggester(configuration);
        suggester.attach(dictionary);

        // create SpellCheck object based on configuration and specify Suggester
        SpellCheck spellCheck = new SpellCheck(configuration);
        spellCheck.setSuggester(suggester);
        //set for jprogress bar
        for (XMLHolder h : xmlBatchHolder) {
            totalCounter += h.size();

        }
        progress = new AtomicInteger(0);
        total = new AtomicInteger(totalCounter);
        mf.setJprogressValues(total, progress);
        //validation process begins here
        String[] invalidWords = { "corporation", "inc.", "city", "corp.", "st.", "co.", "ltd." };
        String[] invalidBoardWords = { "other", "oth" };
        String[] validWords = { "loc", "to", "ext", "local" };
        String[] invalidCharacters = { ",", "/", "\\", "[", "]", "\"", ":", "^", "{", "}", "%", "+", "#", "(",
                ")" };
        String[] splitter;
        String tempURL;
        SimpleDateFormat sdf = new SimpleDateFormat("YYYY/MM/DD");
        SimpleDateFormat fiscalYear = new SimpleDateFormat("MM/DD");
        sdf.setLenient(false);
        Set<String> officerList = new HashSet<>();
        List<Double> percentOwnership = new ArrayList<>();
        UrlValidator urlValidator = new UrlValidator();
        Date date = null;
        for (XMLHolder h : xmlBatchHolder) {
            for (Field f : h) {
                mf.loader("Validating fields: ", false);
                if (!f.getType().equals("none") && !f.getValue().equals("*N/A")) {
                    switch (f.getType()) {
                    case "city":
                        if (f.getValue().isEmpty() || f.getValue().equals("")) {
                            f.add("Address is empty");
                        } else {
                            if (hasWhiteSpaceTrailing(f.getValue())) {
                                f.add("has trailing white space ");
                            }
                            if (cityList.indexOf(f.getValue()) < 0) {
                                f.add("City not found on list!");
                            }
                        }

                        break;
                    case "province":
                        if (f.getValue().isEmpty() || f.getValue().equals("")) {
                            f.add("Address is empty");
                        } else {
                            if (hasWhiteSpaceTrailing(f.getValue())) {
                                f.add("has trailing white space ");
                            }
                            if (provinceList.indexOf(f.getValue()) < 0) {
                                f.add("Province not found on list!");
                            }
                        }

                        break;
                    case "tel":
                        if (!f.getValue().isEmpty() || !f.getValue().equals("")) {
                            //                                    if (f.getValue().matches("[a-z A-Z]+")) {
                            if (f.getValue().matches(".*[a-zA-Z]+.*")) {
                                for (String s : validWords) {
                                    if (!f.getValue().contains(s)) {
                                        f.add("Invalid telephone number");
                                    }
                                }
                            }

                            if (f.getValue().replace(" ", "").replace("-", "").length() < 7
                                    || f.getValue().replace(" ", "").replace("-", "").length() > 8) {
                                f.add("Invalid telephone number length");
                            }

                            if (hasWhiteSpaceTrailing(f.getValue())) {
                                f.add("has trailing white space ");
                            }
                            if (StringUtils.countMatches(f.getValue(), "-") > 2) {
                                f.add("Invalid telephone number");
                            }

                            for (String c : invalidCharacters) {
                                if (f.getValue().contains(c)) {
                                    f.add("Contains invalid character [ " + c + " ]");
                                    break;
                                }
                            }
                        }
                        break;
                    case "fax":
                        if (!f.getValue().isEmpty() || !f.getValue().equals("")) {
                            //                                    if (f.getValue().matches("[a-z A-Z]+")) {
                            if (f.getValue().matches(".*[a-zA-Z]+.*")) {
                                for (String s : validWords) {
                                    if (!f.getValue().contains(s)) {
                                        f.add("Invalid fax number");
                                    }
                                }
                            }
                            if (f.getValue().replace(" ", "").length() < 6) {
                                f.add("Invalid fax number");
                            }
                            if (StringUtils.countMatches(f.getValue(), "-") > 1) {
                                f.add("Invalid fax number");
                            }
                            if (hasWhiteSpaceTrailing(f.getValue())) {
                                f.add("has trailing white space ");
                            }
                            for (String c : invalidCharacters) {
                                if (f.getValue().contains(c)) {
                                    f.add("Contains invalid character [ " + c + " ]");
                                    break;
                                }
                            }
                        }
                        break;
                    case "person":
                        if (!f.getValue().isEmpty() || !f.getValue().equals("")) {
                            if (!f.getValue().matches("[a-zA-Z\\.,\\- ()]+")) {
                                f.add("Invalid name");
                            }
                            if (f.getValue().matches("[a-z ]+")) {
                                f.add("All small caps");
                            }
                            if (f.getValue().matches("\\w+")) {
                                f.add("Only one word");
                            }
                            if (f.getValue().replace(" ", "").length() > 30) {
                                f.add("More than 30 characters.");
                            }
                            if (f.getValue().replace(" ", "").length() < 2) {
                                f.add("Invalid name.");
                            }
                            if (hasWhiteSpaceTrailing(f.getValue())) {
                                f.add("has trailing white space ");
                            }
                        }
                        break;
                    case "email":
                        if (!f.getValue().isEmpty() || !f.getValue().equals("")) {
                            if (!EmailValidator.getInstance(true).isValid(f.getValue())) {
                                f.add("Invalid email");
                            }
                        }
                        break;
                    case "website":
                        if (!f.getValue().isEmpty() || !f.getValue().equals("")) {
                            if (!f.getValue().contains("http")) {
                                tempURL = "http://" + f.getValue();
                            } else {
                                tempURL = f.getValue();
                            }
                            if (!urlValidator.isValid(tempURL)) {
                                f.add("Invalid website");
                            }
                            if (hasWhiteSpaceTrailing(f.getValue())) {
                                f.add("has trailing white space ");
                            }
                        }
                        break;
                    case "name":
                        officerList.add(f.getValue());
                        if (!f.getValue().isEmpty() || !f.getValue().equals("")) {
                            if (!f.getValue().matches("[a-zA-Z\\.,\\-() ]+")) {
                                f.add("Invalid name");
                            }
                            if (f.getValue().replace(" ", "").length() > 30) {
                                f.add("More than 50 characters.");
                            }
                            if (f.getValue().matches("[a-z ]+")) {
                                f.add("All small caps");
                            }
                            if (f.getValue().matches("\\w+")) {
                                f.add("Only one word");
                            }
                            if (f.getValue().replace(" ", "").length() < 2) {
                                f.add("Invalid name.");
                            }
                            if (hasWhiteSpaceTrailing(f.getValue())) {
                                f.add("has trailing white space ");
                            }
                            for (String s : invalidWords) {
                                if (f.getValue().contains(s)) {
                                    f.add("Contains invalid word: " + s);
                                    break;
                                }
                            }
                        }
                        break;
                    case "stockholder":
                        officerList.add(f.getValue());
                        if (!f.getValue().isEmpty() || !f.getValue().equals("")) {
                            if (!f.getValue().matches("[a-zA-Z\\.,\\-() ]+")) {
                                f.add("Invalid name");
                            }
                            if (f.getValue().replace(" ", "").length() > 30) {
                                f.add("More than 50 characters.");
                            }
                            if (f.getValue().matches("[a-z ]+")) {
                                f.add("All small caps");
                            }
                            if (f.getValue().matches("\\w+")) {
                                f.add("Only one word");
                            }
                            if (f.getValue().replace(" ", "").length() < 2) {
                                f.add("Invalid name.");
                            }
                            if (hasWhiteSpaceTrailing(f.getValue())) {
                                f.add("has trailing white space ");
                            }
                            for (String s : invalidWords) {
                                if (f.getValue().contains(s)) {
                                    f.add("Contains invalid word: " + s);
                                    break;
                                }
                            }
                        }
                        break;
                    case "board":
                        if (!f.getValue().isEmpty() || !f.getValue().equals("")) {
                            if (!f.getValue().matches("[a-zA-Z\\.,\\-() ]+")) {
                                f.add("Invalid position");
                            }
                            for (String c : invalidCharacters) {
                                if (f.getValue().contains(c)) {
                                    f.add("Contains invalid character [ " + c + " ]");
                                    break;
                                }
                            }
                            for (String c : invalidBoardWords) {
                                if (f.getValue().contains(c)) {
                                    f.add("Contains invalid word [ " + c + " ]");
                                    break;
                                }
                            }

                            if (f.getValue().equalsIgnoreCase("N") || f.getValue().equalsIgnoreCase("Y")) {
                                f.add("is letter " + f.getValue() + " only");
                            }
                            if (Character.isLowerCase(f.getValue().charAt(0))) {
                                f.add("starts with a lower case letter");
                            }

                            spellCheck.setText(f.getValue(), Constants.DOC_TYPE_TEXT, "en");
                            spellCheck.check();
                            if (spellCheck.hasMisspelt()) {
                                f.add("word is misspelled.");
                            }

                        }
                        break;
                    case "corporation":
                        if (companyList.indexOf(f.getValue().toUpperCase()) < 0) {
                            f.add("Company name not found on table.");
                        }
                        break;
                    case "sec":
                        if (StringUtils.countMatches(f.getValue(), "-") > 1) {
                            f.add("Invalid SEC number");
                        }
                        if (f.getValue().replace(" ", "").length() > 9) {
                            f.add("SEC number more than 9 digits.");
                        }
                        if (hasWhiteSpaceTrailing(f.getValue())) {
                            f.add("SEC has trailing white space.");
                        }
                        for (String c : invalidCharacters) {
                            if (f.getValue().contains(c)) {
                                f.add("Contains invalid character [ " + c + " ]");
                                break;
                            }
                        }
                        break;
                    case "tin":
                        if (f.getValue().isEmpty() || f.getValue().equals("")) {
                            f.add("TIN is empty");
                        }
                        if (hasWhiteSpaceTrailing(f.getValue())) {
                            f.add("TIN has trailing white space.");
                        }
                        if (!f.getValue().matches("[0-9]+")) {
                            f.add("invalid TIN number");
                        }
                        if (f.getValue().replace(" ", "").replace("-", "").length() > 12
                                || f.getValue().replace(" ", "").replace("-", "").length() < 9) {
                            f.add("TIN number invalid length.");
                        }
                        if (StringUtils.countMatches(f.getValue(), "-") > 1) {
                            f.add("Invalid TIN number");
                        }
                        for (String c : invalidCharacters) {
                            if (f.getValue().contains(c)) {
                                f.add("Contains invalid character [ " + c + " ]");
                                break;
                            }
                        }
                        break;
                    case "nationality":
                        if (!f.getValue().isEmpty() || !f.getValue().equals("")) {
                            if (nationalityList.indexOf(f.getValue()) < 0) {
                                f.add("nationality is misspelled.");
                            }
                        }
                        break;
                    case "purpose":
                        splitter = f.getValue().split(" ");
                        for (int i = 0; i < splitter.length; i++) {
                            spellCheck.setText(splitter[i], Constants.DOC_TYPE_TEXT, "en");
                            spellCheck.check();
                            if (spellCheck.hasMisspelt()) {
                                f.add("word is misspelled. ( " + spellCheck.getMisspelt() + " )");
                            }
                        }
                        break;
                    case "periodCovered":
                        try {
                            date = sdf.parse(f.getValue());
                            if (!f.getValue().equals(sdf.format(date))) {
                                f.add("Invalid date format");
                            }
                        } catch (ParseException ex) {
                            f.add("Invalid date format");
                        }
                        break;
                    case "fiscalYear":
                        try {
                            date = fiscalYear.parse(f.getValue());
                            if (!f.getValue().equals(sdf.format(date))) {
                                f.add("Invalid date format");
                            }
                        } catch (ParseException ex) {
                            f.add("Invalid date format");
                        }
                        break;
                    case "position":
                        if (f.getValue().contains("\\d+")) {
                            f.add("Invalid position/designation");
                        }
                        if (f.getValue().replace(" ", "").length() > 10
                                || f.getValue().replace(" ", "").length() < 3) {
                            f.add("More than 30 characters.");
                        }
                        break;
                    case "shareType":
                        if (f.getValue().toLowerCase().contains("total")) {
                            f.add("Share type contains total.");
                        }

                        if (f.getValue().replace(" ", "").length() > 20) {
                            f.add("Share type More than 20 characters.");
                        }
                        break;
                    case "ownership":
                        percentOwnership.add(Double.parseDouble(f.getValue()));
                        if (Double.parseDouble(f.getValue()) > 100) {
                            f.add("Percent ownership more than 100%");
                        }
                        break;
                    default:
                        break;
                    }
                } else if (f.getType().equals("tin") && f.getValue().equals("*N/A")) {
                    f.add("TIN is N/A");
                }
            }
        }

    } catch (EncryptedDocumentException | SuggesterException ex) {
        Logger.getLogger(ValidationProcess.class.getName()).log(Level.SEVERE, null, ex);
    }
    return xmlBatchHolder;
}

From source file:org.kuali.kfs.gl.businessobject.OriginEntryFull.java

protected java.sql.Date parseDate(String sdate, boolean beLenientWithDates) throws ParseException {
    if ((sdate == null) || (sdate.trim().length() == 0)) {
        return null;
    } else {/* ww w. j a  va2 s  .  co m*/

        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
        sdf.setLenient(beLenientWithDates);

        java.util.Date d = sdf.parse(sdate);
        return new Date(d.getTime());
    }
}

From source file:com.eleybourn.bookcatalogue.utils.Utils.java

/**
 * Attempt to parse a date string based on a range of possible formats; allow
 * for caller to specify if the parsing should be strict or lenient.
 * //from  www.j  av a2  s.  c  o m
 * @param s            String to parse
 * @param lenient      True if parsing should be lenient
 * 
 * @return            Resulting date if parsed, otherwise null
 */
private static Date parseDate(String s, boolean lenient) {
    Date d;
    for (SimpleDateFormat sdf : mParseDateFormats) {
        try {
            sdf.setLenient(lenient);
            d = sdf.parse(s);
            return d;
        } catch (Exception e) {
            // Ignore 
        }
    }
    // All SDFs failed, try locale-specific...
    try {
        java.text.DateFormat df = java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT);
        df.setLenient(lenient);
        d = df.parse(s);
        return d;
    } catch (Exception e) {
        // Ignore 
    }
    return null;
}

From source file:general.me.edu.dgtmovil.dgtmovil.formregisestudiante.FormEstudDosFragment.java

public boolean esFecha(String fecha) {

    SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy", Locale.getDefault());
    Date fna = null;/*from www .j ava  2s  .  c o  m*/
    boolean respuesta = false;
    if (fecha.indexOf(" ") != -1) {
        fecha = fecha.substring(0, fecha.indexOf(" "));
    }
    try {
        df.setLenient(false);
        fna = df.parse(fecha);
        respuesta = true;
    } catch (ParseException e) {
        e.printStackTrace();
        respuesta = false;
    }
    return respuesta;

}

From source file:edu.cornell.kfs.fp.batch.service.impl.AdvanceDepositServiceImpl.java

private Timestamp getFormattedTimestamp(AchIncomeFile achIncomeFile, String fieldName) {
    String fileDateTime = achIncomeFile.getFileDate() + achIncomeFile.getFileTime();

    // need to use 24 hour format, since otherwise exception will be thrown if the time falls in PM range.
    SimpleDateFormat dateFormat = new SimpleDateFormat(CuFPConstants.ACH_INCOME_FILE_DATE_FORMAT);
    dateFormat.setLenient(false);

    try {/*from w w w .j a  v  a 2s. co  m*/
        java.util.Date parsedDate = dateFormat.parse(fileDateTime);
        return new Timestamp(parsedDate.getTime());
    } catch (ParseException e) {
        throw new FormatException(
                fieldName + " must be of the format " + CuFPConstants.ACH_INCOME_FILE_DATE_FORMAT + "\n" + e);
    }
}

From source file:es.pode.administracion.presentacion.planificador.crearTarea.CrearTareaControllerImpl.java

/**
 * Mtodo que discrimina la tarea a crear
 * //w  w w. j  a  va 2s  .  co  m
 * Retorna 1: Carga de ODEs 2: Reindexado 3: Eliminar ODEs 4:Infome fecha 5:Informe rango 6:Informe usuario 7:Informe Federado 8:Informe catalogo
 * 
 * @param mapping
 * @param request
 * @param response
 * @throws Exception
 */
public final String crearTarea(ActionMapping mapping, CrearTareaForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    if (log.isDebugEnabled())
        log.debug("CREAR TAREA");

    TrabajoVO trabajo = new TrabajoVO();
    trabajo.setTrabajo(form.getTrabajo());

    Boolean existe = this.getSrvPlanificadorService().existeTrabajo(trabajo);

    /* Comprobamos si la tarea ya existe */
    try {
        if (existe.booleanValue())
            throw new ValidatorException("{tareas.tareaExiste}");
    } catch (ValidatorException e2) {
        saveErrorMessage(request, "tareas.tareaExiste");
        return "Error";
    }

    /* Comprobamos si el nombre de tarea tiene caracteres raros */
    try {
        if (!utilidades.validacionCaracter(form.getTrabajo()))
            throw new ValidatorException("{tareas.nombreIncorrecto}");
    } catch (ValidatorException e2) {
        saveErrorMessage(request, "tareas.nombreIncorrecto");
        return "Error";
    }

    String dia = new String(form.getDia());
    String mes = new String(form.getMes());
    String anio = new String(form.getAnio());
    String hora = new String(form.getHora());
    String minutos = new String(form.getMinutos());

    if (dia.equalsIgnoreCase("") || mes.equalsIgnoreCase("") || anio.equalsIgnoreCase("")
            || hora.equalsIgnoreCase("") || minutos.equalsIgnoreCase("")) {
        log.error("Error al introducir la fecha.");
        throw new ValidatorException("{tareas.errors.dateHora.required}");
    }
    //}catch(Exception e)
    //{
    //throw new ValidatorException("{tareas.errors.fecha.incorrecta}");
    //}
    try {
        new Integer(dia).intValue();
        new Integer(mes).intValue();
        new Integer(anio).intValue();

    } catch (Exception e) {
        log.error("Alguno de los campos de la fecha no son nmeros");
        throw new ValidatorException("{tareas.fechaIncorrecta}");
    }

    try {
        new Integer(hora).intValue();
        new Integer(minutos).intValue();

    } catch (Exception e) {
        log.error("Alguno de los campos de la hora no son nmeros");
        throw new ValidatorException("{tareas.horaIncorrecta}");
    }

    try {
        if (log.isDebugEnabled())
            log.debug("VALIDAMOS LAS FECHAS");
        Date fechaActual = new Date();
        SimpleDateFormat format = new SimpleDateFormat("ddMMyyyyHHmmss");
        format.setLenient(false);
        Date fechaIn = null;

        if (log.isDebugEnabled())
            log.debug("antes de validar la hora");
        boolean horaValida = utilidades.validacionHoraHHMM(hora, minutos);

        if (log.isDebugEnabled())
            log.debug("horaValida es " + horaValida);
        boolean fechaValida = utilidades.validacionFechaDDMMAAAAHHMM(dia, mes, anio, "yyyyMMdd");

        if (log.isDebugEnabled())
            log.debug("fechaValida es " + fechaValida);
        if (!fechaValida && !horaValida)
            throw new ValidatorException("{tareas.fechaYHoraIncorrectas}");

        if (!horaValida)
            throw new ValidatorException("{tareas.horaIncorrecta}");

        if (!fechaValida)
            throw new ValidatorException("{tareas.fechaIncorrecta}");

        if ((new Integer(mes).intValue() < 10) && (mes.length() == 1))
            mes = "0" + mes;

        if ((new Integer(dia).intValue() < 10) && (dia.length() == 1))
            dia = "0" + dia;

        if ((new Integer(hora).intValue() < 10) && (hora.length() == 1))
            hora = "0" + hora;

        if ((new Integer(minutos).intValue() < 10) && (minutos.length() == 1))
            minutos = "0" + minutos;

        log.debug("dia " + dia + " mes " + mes + " anio " + anio + " hora " + hora + " minutos " + minutos);
        fechaIn = format.parse(dia + mes + anio + hora + minutos + "59");
        if (fechaActual.getTime() > fechaIn.getTime()) {
            log.error("La fecha introducida es anterior a la actual");
            throw new ValidatorException("{tareas.fechaAnteriorActual}");
        }

    } catch (java.text.ParseException pe) {
        log.error("Error al introducir la fecha " + pe);
        throw new ValidatorException("{tareas.errors.fecha.incorrecta}");
    } catch (ValidatorException e2) {
        log.error("e2 " + e2);
        throw e2;

    }

    //seleccionamos la 2 pantalla a la que se debe ir dependiendo del tipo de tarea seleccionada

    String tipoTarea = null;
    String tipoTareaDevolver = null;
    try {

        if (log.isDebugEnabled())
            log.debug("obtenerTipoInforme");
        tipoTarea = form.getTipoTarea();

        //Si el tipoTarea es Reindexado, carga ODEs o eliminar ODEs el tipo tarea se mantiene
        if (tipoTarea.equalsIgnoreCase("estadoOdes") || tipoTarea.equalsIgnoreCase("operacionesRealizadas")
                || tipoTarea.equalsIgnoreCase("nivelAgregacion")
                || tipoTarea.equalsIgnoreCase("coberturaCurricular")
                || tipoTarea.equalsIgnoreCase("odesLicencias") || tipoTarea.equalsIgnoreCase("usuarios")
                || tipoTarea.equalsIgnoreCase("procesosPlanificados")) {
            if (log.isDebugEnabled())
                log.debug("cargo informe con fechas");
            tipoTareaDevolver = "InformeFecha";

        } else if (tipoTarea.equalsIgnoreCase("terminosBusqueda") || tipoTarea.equalsIgnoreCase("masValorado")
                || tipoTarea.equalsIgnoreCase("masMostrado") || tipoTarea.equalsIgnoreCase("masPrevisualizado")
                || tipoTarea.equalsIgnoreCase("masVisualizado") || tipoTarea.equalsIgnoreCase("masDescargado")
                || tipoTarea.equalsIgnoreCase("tamanio")) {
            if (log.isDebugEnabled())
                log.debug("cargo informe con rango");
            tipoTareaDevolver = "InformeFechaRango";
        } else if (tipoTarea.equalsIgnoreCase("odesUsuario")) {

            if (log.isDebugEnabled())
                log.debug("cargo informe con usuario");
            tipoTareaDevolver = "InformeFechaUsuario";

        } else if (tipoTarea.indexOf("Federada") != -1) {
            tipoTareaDevolver = "InformeFederado";
        }

        else if (tipoTarea.equalsIgnoreCase("repositorio")) {
            tipoTareaDevolver = "InformeCatalogo";
        } else
            tipoTareaDevolver = tipoTarea;

        if (log.isDebugEnabled())
            log.debug("tipoTarea -> " + tipoTarea);

    } catch (Exception e) {
        saveErrorMessage(request, "tareas.error");
        return "Error";
    }

    if (log.isDebugEnabled())
        log.debug("devuelvo el tipo de tarea -> " + tipoTareaDevolver);
    return (String) tipoTareaDevolver;
}