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:Main.java

public static void main(String[] args) {
    try {//from w  w w.j  a va2  s  .c om

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = sdf.parse("2015-12-31");
        Date date2 = sdf.parse("2015-01-31");

        System.out.println(sdf.format(date1));
        System.out.println(sdf.format(date2));

        if (date1.after(date2)) {
            System.out.println("Date1 is after Date2");
        }

        if (date1.before(date2)) {
            System.out.println("Date1 is before Date2");
        }

        if (date1.equals(date2)) {
            System.out.println("Date1 is equal Date2");
        }

    } catch (ParseException ex) {
        ex.printStackTrace();
    }
}

From source file:MainClass.java

public static void main(String[] args) throws ParseException {
    try {//w  w w.  java  2 s .c  o m
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
        String date = "2003/01/10";
        java.util.Date utilDate = formatter.parse(date);
        java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
        System.out.println("date:" + date);
        System.out.println("sqlDate:" + sqlDate);
    } catch (ParseException e) {
        System.out.println(e.toString());
        e.printStackTrace();
    }

}

From source file:MainClass.java

public static void main(String[] args) {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
    String date = "2003/01/10";
    java.util.Date utilDate = null;
    try {//from   w  w  w  .  ja  va2s .  co  m
        utilDate = formatter.parse(date);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    System.out.println("date:" + date);
    System.out.println("utilDate:" + utilDate);

}

From source file:MainClass.java

public static void main(String[] args) throws ParseException {
    int year = 2003;
    int month = 12;
    int day = 12;

    String date = year + "/" + month + "/" + day;
    java.util.Date utilDate = null;

    try {// w w  w  .j ava2s  .c  o  m
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
        utilDate = formatter.parse(date);
        System.out.println("utilDate:" + utilDate);
    } catch (ParseException e) {
        System.out.println(e.toString());
        e.printStackTrace();
    }

}

From source file:Main.java

public static void main(String[] args) {
    String dateString = "20140316";

    try {//from www  . j a v a 2 s .c om
        System.out.println(previousDateString(dateString));
    } catch (ParseException e) {
        System.out.println("Invalid date string");
        e.printStackTrace();
    }
}

From source file:Person.java

public static void main(String[] args) {
    SimpleDateFormat df = new SimpleDateFormat("mm-dd-yyyy");
    ArrayList<Person> people;
    people = new ArrayList<Person>();
    try {/* ww w.j a  v a 2  s.com*/
        people.add(new Person("A", 9, df.parse("12-12-2014")));
        people.add(new Person("B", 2, df.parse("1-12-2013")));
        people.add(new Person("C", 4, df.parse("12-2-2012")));
    } catch (ParseException e) {
        e.printStackTrace();
    }

    Collections.sort(people, new CompId());
    System.out.println("BY ID");
    for (Person p : people) {
        System.out.println(p.toString());
    }

    Collections.sort(people, new CompDate(false));
    System.out.println("BY Date asc");
    for (Person p : people) {
        System.out.println(p.toString());
    }
    Collections.sort(people, new CompDate(true));
    System.out.println("BY Date desc");
    for (Person p : people) {
        System.out.println(p.toString());
    }

}

From source file:com.tomdoel.mpg2dcm.Xml2Dicom.java

public static void main(String[] args) {
    try {/*w w w .jav a 2s. co m*/
        final Options helpOptions = new Options();
        helpOptions.addOption("h", false, "Print help for this application");

        final DefaultParser parser = new DefaultParser();
        final CommandLine commandLine = parser.parse(helpOptions, args);

        if (commandLine.hasOption('h')) {
            final String helpHeader = "Converts an endoscopic xml and video files to Dicom\n\n";
            String helpFooter = "\nPlease report issues at github.com/tomdoel/mpg2dcm";

            final HelpFormatter helpFormatter = new HelpFormatter();
            helpFormatter.printHelp("Xml2Dcm xml-file dicom-output-path", helpHeader, helpOptions, helpFooter,
                    true);

        } else {
            final List<String> remainingArgs = commandLine.getArgList();
            if (remainingArgs.size() < 2) {
                throw new org.apache.commons.cli.ParseException("ERROR : Not enough arguments specified.");
            }

            final String xmlInputFileName = remainingArgs.get(0);
            final String dicomOutputPath = remainingArgs.get(1);
            EndoscopicXmlToDicomConverter.convert(new File(xmlInputFileName), dicomOutputPath);
        }
    } catch (org.apache.commons.cli.ParseException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        e.printStackTrace();
    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

From source file:eu.optimis.infrastructureproviderriskassessmenttool.core.riskmonitoring.MonClientCommandline.java

public static void main(String[] args) {

    //PropertyConfigurator.configure(ConfigManager.getConfigFilePath(ConfigManager.LOG4J_CONFIG_FILE));
    log.info("IPRA: Test Monitoring Client...");
    PropertiesConfiguration configOptimis = ConfigManager
            .getPropertiesConfiguration(ConfigManager.OPTIMIS_CONFIG_FILE);

    // Test Monitoring Access
    getClient mclient = new getClient(configOptimis.getString("optimis-ipvm"),
            Integer.parseInt(configOptimis.getString("monitoringport")),
            configOptimis.getString("monitoringpath"));
    /*  //w  w w. j  a v a  2  s .c  o  m
      CloudOptimizerRESTClient CoClient = new CloudOptimizerRESTClient(rb.getString("config.coservicehost"), Integer.parseInt(rb.getString("config.coserviceport")), "CloudOptimizer");
              
     System.out.println(CoClient.getNodesId().get(0));
     System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
     System.out.println(CoClient.getPhysicalResource("optimis1"));
     System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
     System.out.println(CoClient.getVMsIdsOfService("DemoApp"));
     System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
              
    */
    MonitoringResourceDatasets mrd = null;
    /*
    mrd = mclient.getReportForAllPhysical();
    MonPrinter(mrd);
            
    mrd = mclient.getReportForAllVirtual();
    MonPrinter(mrd);
    */
    //mrd = mclient.getLatestReportForPhysical("optimis1");
    //mrd = mclient.getLatestReportForMetricName("free_memory","physical");
    //mrd = mclient.getReportForService("DemoApp");
    DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    Date start = null;
    try {
        start = df.parse("01/01/2010");
    } catch (ParseException e) {
        e.printStackTrace();
    }

    Date end = new Date();

    //mrd = mclient.getReportForPartMetricName("status", "physical", start, end);
    //MonPrinter(mrd);
    mrd = mclient.getReportForPartMetricName("vm_state", "virtual", start, end);
    MonPrinter(mrd);
}

From source file:edu.lternet.pasta.client.EmlUtility.java

/**
 * @param args   String array with three arguments:
 *   arg[0] absolute path to the input XML file
 *   arg[1] absolute path to the output HTML file
 *   arg[2] absolute path to the EML XSLT stylesheet
 *//*from   w  w w  .j  av a2 s . c o m*/
public static void main(String[] args) {

    String inputPath = args[0];
    String outputPath = args[1];
    String emlXslPath = args[2];
    ConfigurationListener.configure();

    File inFile = new File(inputPath);
    File outFile = new File(outputPath);
    String eml = null;

    try {
        eml = FileUtils.readFileToString(inFile);
    } catch (IOException e1) {
        logger.error(e1.getMessage());
        e1.printStackTrace();
    }

    EmlUtility eu = null;

    try {
        eu = new EmlUtility(eml);
    } catch (ParseException e) {
        logger.error(e.getMessage());
        e.printStackTrace();
    }

    String html = eu.xmlToHtml(emlXslPath, null);

    try {
        FileUtils.writeStringToFile(outFile, html);
    } catch (IOException e) {
        logger.error(e.getMessage());
        e.printStackTrace();
    }

}

From source file:com.jaeksoft.searchlib.crawler.web.spider.HttpAbstract.java

public final static void main(String[] argv) {
    for (ThreadSafeDateFormat dateFormat : httpDatesFormats) {
        try {//from   w  w  w.j  a v a  2  s .  co m
            System.out.println(dateFormat.parse("Thu, 21 Feb 2013 20:11:52 GMT").getTime());
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}