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:com.modeln.batam.connector.wrapper.Commit.java

public static Commit fromJSON(JSONObject obj) {
    String buildId = (String) obj.get("build_id");
    String buildName = (String) obj.get("build_name");
    String commitId = (String) obj.get("commit_id");
    String url = (String) obj.get("url");
    String author = (String) obj.get("author");
    String dateCommitted = (String) obj.get("date_committed");
    DateFormat dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy Z");
    try {//from  w  w w  .  j  av a  2 s.  co  m
        return new Commit(buildId, buildName, commitId, url, author,
                dateCommitted == null ? null : dateFormat.parse(dateCommitted));
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

From source file:com.alcatel_lucent.nz.wnmsextract.reader.CSVReader.java

/**
 * String tokeniser method will split up a CSV file by row and column 
 * returning a List<List<String>>
 * @param in/*  w w w  .j a  va  2 s. c om*/
 * @param struct
 * @return
 */
public static ArrayList<ArrayList<String>> read(BufferedReader in, ArrayList<ColumnStructure> struct) {
    ArrayList<ArrayList<String>> dmap = new ArrayList<ArrayList<String>>();
    CSVParser parser = new CSVParser(in, CSVReader.strategy);

    //if header
    try {
        //[consume header]
        //String[] header = 
        parser.getLine();

        //and body
        String[] line = null;

        while ((line = parser.getLine()) != null) {
            ArrayList<String> list = new ArrayList<String>();

            for (int i = 0; i < line.length; i++) {
                ColumnStructure cs = struct.get(i);
                switch (cs) {
                case VC:
                    list.add(line[i]);
                    break;
                case TS:
                    Calendar cal = Calendar.getInstance();
                    cal.setTime(DATA_DF.parse(line[i]));
                    list.add(ALUDBUtilities.ALUDB_DF.format(cal.getTime()));
                    break;
                case FL:
                    list.add(String.valueOf(validateFloat(Float.parseFloat(line[i]))));
                    break;
                case IT:
                    list.add(String.valueOf(validateInt(Integer.parseInt(line[i]))));
                    break;
                default:
                    list.add(line[i]);
                }
            }

            dmap.add(list);
        }
    } catch (IOException ioe) {
        // TODO Auto-generated catch block
        ioe.printStackTrace();
    } catch (ParseException pe) {
        // TODO Auto-generated catch block
        pe.printStackTrace();
    }

    return dmap;
}

From source file:com.sam_chordas.android.stockhawk.data.FetchDetailStockTask.java

public static String get30daysTimeStamp() {
    SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
    Date now = new Date();
    String sToday = sdfDate.format(now);
    Calendar c = Calendar.getInstance();
    try {/*from  www . j a v  a 2  s  . c o  m*/
        c.setTime(sdfDate.parse(sToday));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    c.add(Calendar.DATE, -35); // number of days to add, can also use Calendar.DAY_OF_MONTH in place of Calendar.DATE

    String output = sdfDate.format(c.getTime());

    return output;
}

From source file:com.beginner.core.utils.DateUtil.java

/**
 * yyyy-MM-dd HH:mm:ss?/*from w ww.j  a  v  a2 s.  com*/
 * @param date    
 * @return       Date
 * @since       1.0.0
 */
public static Date str2Date(String date) {
    if (Tools.isNotEmpty(date)) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            return sdf.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return new Date();
    } else {
        return null;
    }
}

From source file:com.taksmind.karma.functions.scheduled.Log.java

public static void uploadFile() throws IOException {
    try {//www  . j a  v  a 2 s  .c o m
        logDirectory = new File("logs");
        if (!logDirectory.isDirectory()) {
            logDirectory.mkdir();
        }
        date = sdf.parse(sdf.format(new Date())).toString().replaceAll(" ", "")
                .replaceAll("[0-9]+:[0-9]+:[0-9]+CDT", "");

        Properties properties = new Properties(); //creates configuration object
        properties.load(new FileInputStream(Main.configuration));
        ftpServer = properties.getProperty("ftpServer");
        ftpUser = properties.getProperty("ftpUser");
        ftpPassword = properties.getProperty("ftpPassword");

        client = new FTPClient();

        client.connect(ftpServer);
        int reply = client.getReplyCode();

        if (!FTPReply.isPositiveCompletion(reply)) {
            client.disconnect();
            System.err.println("FTP server refused connection.");
        }

        if (client.login(ftpUser, ftpPassword)) {
            client.enterLocalPassiveMode();
            String localFile = logDirectory.getAbsolutePath() + "/" + date + ".log";
            String remoteFile = "/downloads/logs/" + date + ".log";
            if (Main.debug) {
                System.out.println(localFile);
                System.out.println(remoteFile);
            }
            FileInputStream fis = new FileInputStream(new File(localFile));
            if (client.storeFile(remoteFile, fis)) {
                System.out.println("File uploaded successfully.");
            } else {
                System.err.println("Uploading file failed..");
            }
            fis.close();
            client.logout();
            client.disconnect();
        } else {
            System.out.println("Could not authenticate with FTP server..");
            client.logout();
        }

    } catch (ParseException e) {
        System.err.println("Error parsing log file");
        e.printStackTrace();
    } catch (SocketException e) {
        System.err.println("some exception happened.");
        e.printStackTrace();
    } catch (IOException e) {
        System.err.println("can not open or upload file.");
        e.printStackTrace();
    } finally {
        if (client.isConnected()) {
            client.disconnect();
        }
    }
}

From source file:com.beginner.core.utils.DateUtil.java

/**
 * ????//from   w  w w  . j  a  v a2  s  .  c  om
 * @param strDate    ?
 * @return String    ??
 * @since          1.0.0
 */
public static String getTimes(String strDate) {
    String resultTimes = "";

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    java.util.Date now;

    try {
        now = new Date();
        java.util.Date date = df.parse(strDate);
        long times = now.getTime() - date.getTime();
        long day = times / (24 * 60 * 60 * 1000);
        long hour = (times / (60 * 60 * 1000) - day * 24);
        long min = ((times / (60 * 1000)) - day * 24 * 60 - hour * 60);
        long sec = (times / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);

        StringBuffer sb = new StringBuffer();
        if (hour > 0) {
            sb.append(hour + "??");
        } else if (min > 0) {
            sb.append(min + "?");
        } else {
            sb.append(sec + "?");
        }
        resultTimes = sb.toString();
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return resultTimes;
}

From source file:com.insightaction.util.DataLoader.java

private static BigDecimal getBigDecimal(String value) {
    DecimalFormatSymbols symbols = new DecimalFormatSymbols();
    symbols.setGroupingSeparator(',');
    symbols.setDecimalSeparator('.');
    String pattern = "#,##0.0#";
    DecimalFormat decimalFormat = new DecimalFormat(pattern, symbols);
    decimalFormat.setParseBigDecimal(true);

    BigDecimal bigDecimal = null;
    try {/* ww  w  .j  ava  2 s.  c o  m*/
        bigDecimal = (BigDecimal) decimalFormat.parse(value);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return bigDecimal;
}

From source file:de.msg.terminfindung.gui.awkwrapper.AwkWrapperTest.java

private static Date parseDate(String dateAsString) {

    try {// w  w  w .  ja  v a  2  s .  c o m
        return dateFormat.parse(dateAsString);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:com.denimgroup.threadfix.service.waflog.RiverbedWebAppFirewallLogParser.java

public static Calendar parseDate(String time) {
    SimpleDateFormat formatter = new SimpleDateFormat(LOG_TIMESTAMP_FORMAT);
    Date date = null;/*from w w  w . ja va2 s  .c  o  m*/

    if (time == null) {
        return null;
    }

    try {
        date = formatter.parse(time);
    } catch (ParseException e) {
        e.printStackTrace();
    }

    if (date == null) {
        return null;
    }

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);

    return calendar;
}

From source file:com.lk.ofo.util.DateUtil.java

public static Date parse(String input, String fmt) {
    SimpleDateFormat sdf = new SimpleDateFormat(fmt);
    try {//from ww  w .j a  v  a 2 s  .c  o m
        return sdf.parse(input);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return null;
}