Example usage for java.text ParseException printStackTrace

List of usage examples for java.text ParseException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:controllers.DatasetController.java

public static Result getSearchResult() {
    Form<DataSet> dc = dataSetForm.bindFromRequest();
    ObjectNode jsonData = Json.newObject();
    String dataSetName = "";
    String agency = "";
    String instrument = "";
    String physicalVariable = "";
    String gridDimension = "";
    String startTime = "";
    String endTime = "";
    Date dataSetStartTime = new Date(0), dataSetEndTime = new Date();

    try {/*  w  w  w .  ja  v  a  2 s  . co  m*/
        dataSetName = dc.field("Dataset Name").value();
        agency = dc.field("Agency").value();
        instrument = dc.field("Instrument").value();
        physicalVariable = dc.field("Physical Variable").value();
        gridDimension = dc.field("Grid Dimension").value();
        startTime = dc.field("Dataset Start Time").value();
        endTime = dc.field("Dataset End Time").value();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMM");

        if (!startTime.isEmpty()) {
            try {
                dataSetStartTime = simpleDateFormat.parse(startTime);
                Date min = new Date(0);
                Date max = new Date();
                if (dataSetStartTime.before(min)) {
                    dataSetStartTime = min;
                } else if (dataSetStartTime.after(max)) {
                    dataSetStartTime = max;
                }
            } catch (ParseException e) {
                System.out.println("Wrong Date Format :" + startTime);
                return badRequest("Wrong Date Format :" + startTime);
            }
        }

        if (!endTime.isEmpty()) {
            try {
                dataSetEndTime = simpleDateFormat.parse(endTime);
                Date min = new Date(0);
                Date max = new Date();
                if (dataSetEndTime.before(min)) {
                    dataSetEndTime = min;
                } else if (dataSetEndTime.after(max)) {
                    dataSetEndTime = max;
                }
            } catch (ParseException e) {
                System.out.println("Wrong Date Format :" + endTime);
                return badRequest("Wrong Date Format :" + endTime);
            }
        }
    } catch (IllegalStateException e) {
        e.printStackTrace();
        Application.flashMsg(APICall.createResponse(ResponseType.CONVERSIONERROR));
    } catch (Exception e) {
        e.printStackTrace();
        Application.flashMsg(APICall.createResponse(ResponseType.UNKNOWN));
    }
    List<DataSet> response = DataSet.queryDataSet(dataSetName, agency, instrument, physicalVariable,
            gridDimension, dataSetStartTime, dataSetEndTime);
    return ok(dataSetList.render(response, dataSetForm));
}

From source file:br.com.surittec.suricdi.core.validation.MaxDateValidator.java

@Override
public void initialize(MaxDate constraintAnnotation) {
    nullable = constraintAnnotation.nullable();
    try {/*from  w  w  w.  j  a  va2s  .  c o m*/
        if (StringUtils.isNotBlank(constraintAnnotation.maxDate()))
            maxDate = formatter.parse(constraintAnnotation.maxDate());
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

From source file:br.com.surittec.suricdi.core.validation.MinDateValidator.java

@Override
public void initialize(MinDate constraintAnnotation) {
    nullable = constraintAnnotation.nullable();
    try {// w w w . j  a  v  a2s.c  om
        if (StringUtils.isNotBlank(constraintAnnotation.minDate()))
            minDate = formatter.parse(constraintAnnotation.minDate());
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

From source file:com.networknt.light.server.DbServiceTest.java

public void testDateFormat() throws Exception {
    String dateString = "2014-11-30T05:00:00.000Z";
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
    try {/* w  ww.j a v a2s  .  c om*/
        Date strToDate = format.parse(dateString);
        System.out.println(strToDate);
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

From source file:br.com.surittec.suricdi.core.validation.DateRangeValidator.java

@Override
public void initialize(DateRange constraintAnnotation) {
    nullable = constraintAnnotation.nullable();
    try {/*  w w w  .  j  a va2s . co m*/
        if (StringUtils.isNotBlank(constraintAnnotation.minDate()))
            minDate = formatter.parse(constraintAnnotation.minDate());
        if (StringUtils.isNotBlank(constraintAnnotation.maxDate()))
            maxDate = formatter.parse(constraintAnnotation.maxDate());
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

From source file:br.com.surittec.surivalidation.validator.DateRangeValidator.java

@Override
public void initialize(DateRange constraintAnnotation) {
    nullable = constraintAnnotation.nullable();
    try {//from w ww  .j a v  a2 s  .c  o  m
        if (StringUtils.isNotBlank(constraintAnnotation.minDate()))
            minDate = DateUtil.toFirstTime(formatter.parse(constraintAnnotation.minDate()));
        if (StringUtils.isNotBlank(constraintAnnotation.maxDate()))
            maxDate = DateUtil.toLastTime(formatter.parse(constraintAnnotation.maxDate()));
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

From source file:com.taurus.compratae.test.ArchivoDbServiceTestCase.java

public void testBuscarTodo() {
    log.debug("Inicio testRecarga");
    setup();//from   w ww  . j  a  v  a  2 s  .  c o  m
    Date fecha1 = new Date();
    SimpleDateFormat formatoDelTexto = new SimpleDateFormat("yyyy-MM-dd");
    String fecha = formatoDelTexto.format(fecha1);

    Date fechaEnviar = null;
    try {
        fechaEnviar = formatoDelTexto.parse(fecha);
    } catch (ParseException ex) {
        ex.printStackTrace();
    }
    Calendar cal = new GregorianCalendar();
    cal.setTimeInMillis(fechaEnviar.getTime());
    cal.add(Calendar.MINUTE, 1439);
    Date fecha2 = new java.sql.Date(cal.getTimeInMillis());
    Archivo archivo = archivoDbService.buscarEntreFechas(fechaEnviar, fecha2);
    log.debug("Fin testRecarga");
}

From source file:org.hil.dao.ChildrenDaoTestCase.java

public void testGenearteCode() {
    Children child = new Children();
    Village village = villageDao.get(new Long(26));
    child.setVillage(village);/*from ww w  . ja va 2s. co m*/
    child.setId(new Long(52));
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    try {
        Date bdate = format.parse("2010-11-10");
        child.setDateOfBirth(bdate);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    childrenDaoExt.generateChildCode(child);
}

From source file:com.joinsystem.goku.common.utils.DateUtil.java

/**
 * //from w  w  w. j  a v a  2s  . c o  m
 * @param date 
 * @param ftm ?
 * @return ?null
 */
public static Date stringToDate(String date, String ftm) {
    SimpleDateFormat sdf = new SimpleDateFormat(ftm);
    try {
        return sdf.parse(date);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

From source file:com.littlehotspot.hadoop.mr.nginx.module.cdf.TestCDFScheduler.java

@Test
public void date() {
    try {/*from w  ww.  j a v a  2  s.c  o  m*/
        String dateString = "28/Mar/2017:11:13:23 +0800";
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss Z", Locale.US);
        Date date = simpleDateFormat.parse(dateString);
        System.out.println(date);
    } catch (ParseException e) {
        e.printStackTrace();
    }
}