Example usage for java.text ParseException getMessage

List of usage examples for java.text ParseException getMessage

Introduction

In this page you can find the example usage for java.text ParseException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:br.org.funcate.dynamicforms.views.GDateView.java

/**
 * @param fragment   the fragment to use.
 * @param attrs attributes.//w  ww  .  j  a v a  2 s.co  m
 * @param parentView parent
 * @param label label
 * @param value value
 * @param constraintDescription constraints
 * @param readonly if <code>false</code>, the item is disabled for editing.
 */
public GDateView(final Fragment fragment, AttributeSet attrs, LinearLayout parentView, String label,
        String value, String constraintDescription, boolean readonly) {
    super(fragment.getActivity(), attrs);

    final Context context = fragment.getActivity();

    LinearLayout textLayout = new LinearLayout(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10, 10, 10, 10);
    textLayout.setLayoutParams(layoutParams);
    textLayout.setOrientation(LinearLayout.VERTICAL);
    parentView.addView(textLayout);

    TextView textView = new TextView(context);
    textView.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    textView.setPadding(2, 2, 2, 2);
    textView.setText(label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription);
    textView.setTextColor(context.getResources().getColor(R.color.formcolor));
    textLayout.addView(textView);

    button = new Button(context);
    button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    button.setPadding(15, 5, 15, 5);

    final SimpleDateFormat dateFormatter = TimeUtilities.INSTANCE.DATEONLY_FORMATTER;
    if (value == null || value.length() == 0) {
        String dateStr = dateFormatter.format(new Date());
        button.setText(dateStr);
    } else {
        button.setText(value);
    }
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            String dateStr = button.getText().toString();
            Date date = null;
            try {
                date = dateFormatter.parse(dateStr);
            } catch (ParseException e) {
                //GPLog.error(this, null, e);
                Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
                date = new Date();
            }
            final Calendar c = Calendar.getInstance();
            c.setTime(date);
            int year = c.get(Calendar.YEAR);
            int month = c.get(Calendar.MONTH);
            int day = c.get(Calendar.DAY_OF_MONTH);

            FormDatePickerFragment newFragment = new FormDatePickerFragment();
            newFragment.setAttributes(year, month, day, button);
            newFragment.show(fragment.getFragmentManager(), "datePicker");
        }
    });
    button.setEnabled(!readonly);

    textLayout.addView(button);
}

From source file:com.marklogic.contentpump.utilities.JSONDocBuilder.java

@Override
public void put(String key, String value) throws Exception {
    try {/*w w  w .  j a  v  a 2 s  .co  m*/
        Object valueObj = datatypeMap.get(key).parse(value);
        generator.writeObjectField(key, valueObj);
    } catch (ParseException e) {
        throw new ParseException("Value " + value + " is not type " + datatypeMap.get(key).name(), 0);
    } catch (Exception e) {
        String msg = e.getMessage();
        if (!msg.contains("missing value")) {
            throw new Exception(msg);
        }
    }

}

From source file:com.sielpe.controller.GestionarCandidatos.java

/**
 * peticion para actualizar un usuario//from   ww  w. j  a v  a  2  s  .  c o m
 *
 * @param request
 * @param response
 * @throws IOException
 * @throws MiExcepcion
 */
public void actualizarUsuario(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String respuesta = "";
    if (request.getParameter("edit") != null) {
        byte[] bytes = null;
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            Date fecha = format.parse(request.getParameter("fechaCandidato"));
            respuesta = facadeDAO.editarCandidato(dtoFactory.crearCandidato(request.getParameter("idCandidato"),
                    request.getParameter("generoCandidato"), fecha, request.getParameter("nombreCandidato"),
                    Integer.parseInt(request.getParameter("listaCandidato")),
                    Integer.parseInt(request.getParameter("eleccionCandidato")), bytes));
            response.sendRedirect("GestionarCandidatos?&msg=" + respuesta);
        } catch (ParseException ex) {
            respuesta = ex.getMessage();
        }
    } else {
        response.sendRedirect("GestionarCandidatos");
    }
}

From source file:in.bookmylab.controllers.Bookings.java

@Action
@Authorize/* w ww  .  j a v  a  2  s.  c o  m*/
public void getSlotsForDate() throws IOException {
    String dt = getRequestParameter("date");
    if (!StringUtils.isEmpty(dt)) {
        try {
            Date d = Utils.parseDate(dt, Constants.DATE_MEDIUM);
            List<ResourceBooking> list = JpaDAO.getInstance().getSlotsByDate(d);
            sendJsonResponse(Status.OK, list);
        } catch (ParseException e) {
            logger.severe("Unparsable input date: " + e.getMessage());
            sendJsonResponse(Status.ERROR, e.getMessage());
        }
    } else {
        sendJsonResponse(Status.ERROR, "Expected a valid input date.");
    }
}

From source file:com.sielpe.controller.GestionarCandidatos.java

/**
 * peticion crear nuevo candidato//w  w  w.  j a  v  a  2 s  .c  om
 *
 * @param request
 * @param response
 * @throws IOException
 * @throws MiExcepcion
 * @throws ServletException
 */
public void nuevoCandidato(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    if (request.getParameter("new") != null) {
        String respuesta = "";
        byte[] bytes = null;
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            Date fecha = format.parse(request.getParameter("fechaCandidato"));
            respuesta = facadeDAO.crearCandidato(dtoFactory.crearCandidato(request.getParameter("idCandidato"),
                    request.getParameter("generoCandidato"), fecha, request.getParameter("nombreCandidato"),
                    Integer.parseInt(request.getParameter("listaCandidato")),
                    Integer.parseInt(request.getParameter("eleccionCandidato")), bytes));
        } catch (ParseException ex) {
            respuesta = ex.getMessage();
        }
        response.sendRedirect("GestionarCandidatos?msg=" + respuesta);
    } else {
        guardarFoto(request, response);
    }
}

From source file:com.zxy.commons.lang.utils.DatesUtils.java

/**
 * ?/*from   w  w w  . j ava  2s  . c o m*/
 * 
 * @param dateString 
 * @param locale locale
 * @return 
 */
public Date toDate(String dateString, Locale locale) {
    if (StringUtils.isBlank(dateString)) {
        return null;
    }
    SimpleDateFormat df = new SimpleDateFormat(this.getDateType(), locale);
    Date date = null;
    try {
        date = df.parse(dateString);
    } catch (ParseException e) {
        log.error(e.getMessage(), e);
    }
    return date;
}

From source file:com.zxy.commons.lang.utils.DatesUtils.java

/**
 * ?/*from  w w  w.java2  s.  co  m*/
 * 
 * @param dateString 
 * @return 
 */
public Date toDate(String dateString) {
    if (StringUtils.isBlank(dateString)) {
        return null;
    }
    SimpleDateFormat df = new SimpleDateFormat(this.getDateType(), Locale.CHINA);
    df.applyPattern(this.getDateType());
    Date date = null;
    try {
        date = df.parse(dateString);
    } catch (ParseException e) {
        log.error(e.getMessage(), e);
    }
    return date;
}

From source file:org.cs.basic.test.util.DateUtils.java

/**,,
 * @param d//ww w.  j  ava  2  s  .  com
 * @return
 */
public static Date date(String d) {
    Calendar now = Calendar.getInstance();
    Date date = null;
    try {
        date = dd.parse(d);
    } catch (ParseException e) {
        System.out.println("????" + e.getMessage());
    }
    now.setTime(date);
    int year = now.get(Calendar.YEAR);
    int month = now.get(Calendar.MONTH);
    int day = now.get(Calendar.DAY_OF_MONTH);
    now.set(year, month, day);
    return now.getTime();
}

From source file:org.gbif.portal.web.content.dataset.OccurrenceDateFilterHelper.java

/**
 * @see org.gbif.portal.web.content.filter.FilterHelper#preProcess(java.util.List, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//* www . ja  v a  2  s  . com*/
public void preProcess(List<PropertyStoreTripletDTO> triplets, HttpServletRequest request,
        HttpServletResponse response) {

    //pick out date triplets
    List<PropertyStoreTripletDTO> dateTriplets = new ArrayList<PropertyStoreTripletDTO>();
    for (PropertyStoreTripletDTO triplet : triplets) {
        if (triplet.getSubject().equals(occurrenceDateSubject)) {
            dateTriplets.add(triplet);
        }
    }
    triplets.removeAll(dateTriplets);

    //process date triplets
    for (PropertyStoreTripletDTO triplet : dateTriplets) {
        if (triplet.getSubject().equals(occurrenceDateSubject)) {
            String tripletObject = (String) triplet.getObject();
            String startDate = null;
            String endDate = null;

            //is it a range or specific date?
            if (tripletObject != null && tripletObject.indexOf('-') > 0) {
                int indexOfSeparator = tripletObject.indexOf('-');
                startDate = tripletObject.substring(0, indexOfSeparator);
                endDate = tripletObject.substring(indexOfSeparator + 1);
            } else {
                startDate = tripletObject;
                endDate = tripletObject;
            }

            try {
                Date start = DateUtil.setTime(DateUtils.parseDate(startDate, new String[] { "ddMMyyyy" }), 0, 0,
                        0);
                Date end = DateUtil.setTime(DateUtils.parseDate(endDate, new String[] { "ddMMyyyy" }), 23, 59,
                        59);

                triplets.add(new PropertyStoreTripletDTO(triplet.getNamespace(), triplet.getSubject(),
                        greaterThanPredicate, start));
                triplets.add(new PropertyStoreTripletDTO(triplet.getNamespace(), triplet.getSubject(),
                        lessThanPredicate, end));
            } catch (ParseException e) {
                logger.warn(e.getMessage(), e);
                //do nothing for this dodgy triplet
            }
        }
    }
}

From source file:com.jaeksoft.searchlib.crawler.file.database.FileInfo.java

private void setFileSystemDate(String d) {
    if (d == null) {
        fileSystemDate = null;/*from   w w w.  j a v  a2 s. co m*/
        return;
    }
    try {
        fileSystemDate = FileItem.dateFormat.parse(d).getTime();
    } catch (ParseException e) {
        Logging.warn(e.getMessage());
        fileSystemDate = null;
    }
}