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.apextom.util.DateUtil.java

/**
 * ??java.util.Date//from w ww .j a v  a2s . c  om
 *
 * @param dateStr   
 * @param formatStr ??
 * @return ??Date
 * @throws ParseException
 */
public static Date strToDate(String dateStr, String formatStr) {
    Date date = null;
    if (dateStr != null && !"".equals(dateStr)) {
        SimpleDateFormat sdf = new SimpleDateFormat(formatStr);
        try {
            date = sdf.parse(dateStr);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
    return date;
}

From source file:de.iisys.schub.processMining.MiningMain.java

private static void test_ProcessMining() {
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm");

    List<ProcessCycle> cycles = new ArrayList<ProcessCycle>();

    // cycle 1 -----
    List<JSONObject> activities = new ArrayList<JSONObject>();

    JSONObject a1_1 = new JSONObject();
    a1_1.put("actor", getActor("baerbel", "Brbel Bitte"));
    a1_1.put("generator", getGenerator("application:liferay-wikis", "Liferay Wikis"));
    a1_1.put("id", "activityentry:315");
    a1_1.put("title", "Brbel Bitte hat die Wikiseite Huawei Watch kostet so viel wie Apple Watch erstellt.");
    a1_1.put("verb", "post");
    a1_1.put("published", "2015-11-13T10:37:41.660Z");
    a1_1.put("object", new JSONObject().put("id", "liferay-wiki-page:55604").put("displayName", "")
            .put("objectType", "liferay-wiki-page").put("url", "").put("content", "version 1.0"));
    activities.add(a1_1);//from www. j a  v a  2 s  .c o m

    JSONObject a1_2 = new JSONObject();
    a1_2.put("actor", getActor("anna", "Anna Alster"));
    a1_2.put("generator", getGenerator("application:liferay-blogs", "Liferay Blogs"));
    a1_2.put("id", "activityentry:316");
    a1_2.put("title", "Anna Alster hat den Blogeintrag target erstellt.");
    a1_2.put("verb", "post");
    a1_2.put("published", "2015-11-13T11:11:44.359Z");
    a1_2.put("object",
            new JSONObject().put("id", "liferay-blog-entry:55701").put("objectType", "liferay-blog-entry"));
    activities.add(a1_2);

    JSONObject a1_3 = new JSONObject();
    a1_3.put("actor", getActor("anna", "Anna Alster"));
    a1_3.put("generator", getGenerator("application:liferay-messageboards", "Liferay Message Boards"));
    a1_3.put("id", "activityentry:317");
    a1_3.put("title", "Anna Alster hat den Forenthread target erstellt.");
    a1_3.put("verb", "add");
    a1_3.put("published", "2015-11-13T11:36:01.817Z");
    a1_3.put("object", new JSONObject().put("id", "liferay-message-board-entry:55717").put("objectType",
            "liferay-message-board-entry"));
    activities.add(a1_3);

    JSONObject a1_31 = new JSONObject();
    a1_31.put("actor", getActor("anna", "Anna Alster"));
    a1_31.put("generator", getGenerator("nuxeo", "Nuxeo"));
    a1_31.put("id", "activityentry:335");
    a1_31.put("title", "Dokument erstellt");
    a1_31.put("verb", "add");
    a1_31.put("published", "2015-11-19T13:31:15.518Z");
    a1_31.put("object",
            new JSONObject().put("id", "25ede30f-5c5e-457b-9d84-58ef14bf73e5").put("displayName", "")
                    .put("objectType", "Document").put("url", "")
                    .put("content", "type: File\nname: Vernetzt und mobil ins i"));
    activities.add(a1_31);

    JSONObject a1_4 = new JSONObject();
    a1_4.put("actor", getActor("zoltan", "Zoltan Zorn"));
    a1_4.put("generator", getGenerator("application:liferay-journal", "Liferay Journal"));
    a1_4.put("id", "activityentry:319");
    a1_4.put("title", "Zoltan Zorn hat den Webcontent-Artikel ... erstellt.");
    a1_4.put("verb", "add");
    a1_4.put("published", "2015-11-13T13:04:14.550Z");
    a1_4.put("object", new JSONObject().put("id", "liferay-journal-entry:55735").put("objectType",
            "liferay-journal-entry"));
    activities.add(a1_4);

    // activities which are NOT similar
    for (int i = 0; i < 24; i++) {
        JSONObject temp = new JSONObject();
        temp.put("actor", getActor("anna", "Anna Alster"));
        temp.put("generator", getGenerator("application:liferay-blogs", "Liferay Blogs"));
        temp.put("title", "Anna Alster hat den Blogeintrag target erstellt.");
        temp.put("verb", "post");
        temp.put("published", "2015-11-13T11:" + i + ":44.359Z");
        temp.put("object",
                new JSONObject().put("id", "liferay-blog-entry:57215").put("objectType", "liferay-blog-entry"));
        activities.add(temp);
    }

    // Doc: Projektvorschlag - Smarte Uhren vernetzen.docx
    ProcessCycle cycle1 = new ProcessCycle("a8953f85-d81c-4cdc-b701-9b653d0008e1", "Project Proposal",
            activities);
    cycle1.addUserId("baerbel");
    cycle1.addUserId("anna");
    try {
        cycle1.setStartDate(df.parse("2015-07-13 12:12"));
        cycle1.setEndDate(df.parse("2015-12-11 13:45"));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    cycles.add(cycle1);

    // cycle 2 -----
    List<JSONObject> activities2 = new ArrayList<JSONObject>();

    JSONObject a2_11 = new JSONObject();
    a2_11.put("actor", getActor("baerbel", "Brbel Bitte"));
    a2_11.put("generator", getGenerator("application:liferay-wikis", "Liferay Wikis"));
    a2_11.put("id", "activityentry:333");
    a2_11.put("title",
            "Brbel Bitte hat die Wikiseite Telekom erwartet Ablsung der klassischen SIM-Karte fr 2016 erstellt.");
    a2_11.put("verb", "post");
    a2_11.put("published", "2015-11-18T14:12:00.421Z");
    a2_11.put("object",
            new JSONObject().put("id", "liferay-wiki-page:56923").put("objectType", "liferay-wiki-page"));
    activities2.add(a2_11);

    JSONObject a2_12 = new JSONObject();
    a2_12.put("actor", getActor("erika", "Erika Ernst"));
    a2_12.put("generator", getGenerator("application:liferay-messageboards", "Liferay Message Boards"));
    a2_12.put("id", "activityentry:337");
    a2_12.put("title", "Erika Ernst hat den Forenthread target erstellt.");
    a2_12.put("verb", "add");
    a2_12.put("published", "2015-11-20T10:06:01.624Z");
    a2_12.put("object", new JSONObject().put("id", "liferay-message-board-entry:57348").put("objectType",
            "liferay-message-board-entry"));
    activities2.add(a2_12);

    JSONObject a2_21 = new JSONObject();
    a2_21.put("actor", getActor("anna", "Anna Alster"));
    a2_21.put("generator", getGenerator("application:liferay-blogs", "Liferay Blogs"));
    a2_21.put("id", "activityentry:328");
    a2_21.put("title", "Anna Alster hat den Blogeintrag target erstellt.");
    a2_21.put("verb", "post");
    a2_21.put("published", "2015-11-17T15:01:33.031Z");
    a2_21.put("object",
            new JSONObject().put("id", "liferay-blog-entry:56353").put("objectType", "liferay-blog-entry"));
    activities2.add(a2_21);

    JSONObject a2_22 = new JSONObject();
    a2_22.put("actor", getActor("anna", "Anna Alster"));
    a2_22.put("generator", getGenerator("application:liferay-blogs", "Liferay Blogs"));
    a2_22.put("id", "activityentry:329");
    a2_22.put("title", "Anna Alster hat den Blogeintrag target erstellt.");
    a2_22.put("verb", "post");
    a2_22.put("published", "2015-11-17T15:07:31.825Z");
    a2_22.put("object",
            new JSONObject().put("id", "liferay-blog-entry:56362").put("objectType", "liferay-blog-entry"));
    activities2.add(a2_22);

    JSONObject a2_31 = new JSONObject();
    a2_31.put("actor", getActor("zoltan", "Zoltan Zorn"));
    a2_31.put("generator", getGenerator("application:liferay-messageboards", "Liferay Message Boards"));
    a2_31.put("id", "activityentry:330");
    a2_31.put("title", "Zoltan Zorn hat den Forenthread target erstellt.");
    a2_31.put("verb", "add");
    a2_31.put("published", "2015-11-17T15:29:52.109Z");
    a2_31.put("object", new JSONObject().put("id", "liferay-message-board-entry:56372").put("objectType",
            "liferay-message-board-entry"));
    activities2.add(a2_31);

    JSONObject a2_32 = new JSONObject();
    a2_32.put("actor", getActor("erika", "Erika Ernst"));
    a2_32.put("generator", getGenerator("application:liferay-blogs", "Liferay Blogs"));
    a2_32.put("id", "activityentry:332");
    a2_32.put("title", "Erika Ernst hat den Blogeintrag target erstellt.");
    a2_32.put("verb", "post");
    a2_32.put("published", "2015-11-17T15:36:11.247Z");
    a2_32.put("object",
            new JSONObject().put("id", "liferay-blog-entry:56395").put("objectType", "liferay-blog-entry"));
    activities2.add(a2_32);

    JSONObject a2_41 = new JSONObject();
    a2_41.put("actor", getActor("baerbel", "Brbel Bitte"));
    a2_41.put("generator", getGenerator("application:liferay-wikis", "Liferay Wikis"));
    a2_41.put("id", "activityentry:339");
    a2_41.put("title",
            "Brbel Bitte hat die Wikiseite Kein anderes Smartphone lsst sich so leicht reparieren wie das Fairphone 2 erstellt.");
    a2_41.put("verb", "post");
    a2_41.put("published", "2015-11-20T10:48:26.810Z");
    a2_41.put("object",
            new JSONObject().put("id", "liferay-wiki-page:57360").put("objectType", "liferay-wiki-page"));
    activities2.add(a2_41);

    JSONObject a2_m1 = new JSONObject();
    a2_m1.put("actor", getActor("baerbel", "Brbel Bitte"));
    a2_m1.put("generator", getGenerator("shindig-socialmessaging", "Social Messenger"));
    a2_m1.put("id", "activityentry:345");
    a2_m1.put("title", "Fragen zur eSim-Karte: Hallo Zoltan,\ndu kennst ...");
    a2_m1.put("verb", "send");
    a2_m1.put("published", "2015-11-26T13:18:14.700Z");
    a2_m1.put("object", new JSONObject().put("id", "messages:22").put("objectType", "message"));
    a2_m1.put("target", new JSONObject().put("id", "zoltan").put("objectType", "person"));
    activities2.add(a2_m1);

    JSONObject a2_m2 = ShindigRESTConnector.getActivity("anna", "activityentry:346"); // social message
    if (a2_m2 != null)
        activities2.add(a2_m2);
    else
        System.out.println("Error loading a2_m2");

    JSONObject a2_m3 = ShindigRESTConnector.getActivity("erika", "activityentry:347"); // social message
    if (a2_m3 != null)
        activities2.add(a2_m3);
    else
        System.out.println("Error loading a2_m3");

    // activities which are NOT similar
    for (int i = 0; i < 24; i++) {
        JSONObject temp = new JSONObject();
        temp.put("actor", getActor("anna", "Anna Alster"));
        temp.put("generator", getGenerator("application:liferay-blogs", "Liferay Blogs"));
        temp.put("title", "Anna Alster hat den Blogeintrag target erstellt.");
        temp.put("verb", "post");
        temp.put("published", "2015-11-13T11:" + i + ":44.359Z");
        temp.put("object",
                new JSONObject().put("id", "liferay-blog-entry:57215").put("objectType", "liferay-blog-entry"));
        activities2.add(temp);
    }

    ProcessCycle cycle2 = new ProcessCycle("08257161-2e56-4299-80da-d41b77968beb", "Project Proposal",
            activities2);
    cycle2.addUserId("baerbel");
    cycle2.addUserId("anna");
    try {
        cycle2.setStartDate(df.parse("2015-10-25 12:32"));
        cycle2.setEndDate(df.parse("2015-12-11 13:45"));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    cycles.add(cycle2);

    ActivityController controller = new ActivityController(cycles);
    controller.startPipeline();
}

From source file:com.clustercontrol.calendar.util.CalendarUtil.java

/**
 *  -  ????????//  w ww .j a va2  s.c o m
 * 
 * @param detailInfo
 * @param date
 * @return ??? True
 */
public static boolean isRunByDetailTime(CalendarDetailInfo detailInfo, Date date) {
    //?  (00:00:00 - 24:00:00)
    long timezoneOffset = HinemosTime.getTimeZoneOffset();
    //null?
    if (detailInfo.getTimeFrom() == null || detailInfo.getTimeTo() == null) {
        m_log.warn("detailInfo.getTime is NULL");
        return false;
    }

    //?????00:00:00?
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
    sdf.setTimeZone(HinemosTime.getTimeZone());
    String strNow = sdf.format(date);
    Date dateNow = null;
    try {
        dateNow = sdf.parse(strNow);
        /*
         * ???????1970/1/1 ???????
         * ?????????????????
         */
        long from = detailInfo.getTimeFrom() + timezoneOffset + dateNow.getTime();
        long to = detailInfo.getTimeTo() + timezoneOffset + dateNow.getTime();
        m_log.trace("this Time       " + date);
        m_log.trace("DetailTimeFrom  " + new Date(from));
        m_log.trace("DetailTimeTo    " + new Date(to));

        //???Long
        Long checkTime = date.getTime();

        //??????
        if (from <= checkTime && checkTime < to) {
            return true;
        }
    } catch (ParseException e) {
        e.printStackTrace();
    }
    // ??????????
    return false;
}

From source file:org.cricket.hawkeye.service.persistence.CricDataPersistenceServiceImpl.java

private static Set<org.cricket.hawkeye.db.Inning> createInnings(String text, Player player) {

    Matcher m = inningsPattern.matcher(text);
    String start = null;//from   w  w  w . j  a  va 2 s  .  c om

    while (m.find()) {
        start = m.group();

    }
    String end = "</table>";

    int i1 = text.indexOf(start);

    int i = text.indexOf("<tbody>", i1);

    int j = text.indexOf(end, i);
    String innings = text.substring(i, j);

    Matcher m2 = p1.matcher(innings);

    int x = 0;

    int count = 0;
    Set<org.cricket.hawkeye.db.Inning> result = new TreeSet<org.cricket.hawkeye.db.Inning>();

    while (m2.find()) {
        String start1 = m2.group();

        x = innings.indexOf(start1, x);

        int y = innings.indexOf("</tr>", x);
        String part = innings.substring(x + start1.length(), y);

        Matcher m3 = p2.matcher(part);

        int k = 0;
        org.cricket.hawkeye.db.Inning inning = new org.cricket.hawkeye.db.Inning();
        inning.setPlayer(player);
        org.cricket.hawkeye.db.Country country = null;

        while (m3.find()) {
            String td = m3.group(1);

            switch (k) {

            case 0:
                int runs = 0;

                if (td.endsWith("DNB")) {
                    inning.setBatted(false);
                    inning.setWasOut(false);

                } else if (td.endsWith("*")) {
                    runs = Integer.parseInt(td.substring(0, td.length() - 1));

                    inning.setRuns(runs);
                    inning.setWasOut(false);

                } else {
                    inning.setRuns(Integer.parseInt(td));

                }
                break;

            case 1:

                inning.setMins(td.equals("-") ? 0 : Integer.parseInt(td));

                break;

            case 2:
                inning.setBallFaced(td.equals("-") ? 0 : Integer.parseInt(td));

                break;

            case 3:
                inning.setFours(td.equals("-") ? 0 : Integer.parseInt(td));

                break;

            case 4:
                inning.setSixes(td.equals("-") ? 0 : Integer.parseInt(td));

                break;

            case 5:
                inning.setStrikeRate(td.equals("-") ? 0 : Float.parseFloat(td));

                break;

            case 6:
                inning.setPositions(td.equals("-") ? 0 : Integer.parseInt(td));

                break;

            case 7:
                inning.setDismissalType(td.equals("-") ? new DismissalType() : new DismissalType(td));

                break;

            case 8:
                inning.setInnings(td.equals("-") ? 0 : Integer.parseInt(td));

                break;

            case 9:

                break;

            case 10:
                country = new org.cricket.hawkeye.db.Country();
                country.setName(td);

                inning.setOpposition(country);

                break;

            case 11:
                Ground ground = new org.cricket.hawkeye.db.Ground();
                System.out.println(td);
                if (td == null || td.isEmpty()) {
                    System.out.println(
                            "empty ground for " + inning.getPlayer() + " of country " + inning.getOpposition());
                }
                ground.setName(td);
                inning.setGround(ground);

                break;

            case 12:
                SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy");

                try {

                    inning.setStartDate(sdf.parse(td));

                } catch (ParseException ex) {
                    System.out.println("Error occurred while paring date");
                    ex.printStackTrace();

                }
                break;

            case 13:
                int odi = Integer.parseInt(td.substring(td.indexOf("#") + 1).trim());
                inning.setOdi(odi);

                break;

            }

            k++;

        }
        x++;
        count++;

        result.add(inning);

    }

    return result;

}

From source file:com.example.cmput301.model.WebService.java

/**
 * Gets list of responses from jsonObject and returns
 * @param jsonTask , task object in json format.
 * @return List<Response>//  w ww . j  a v a 2  s  .  c o  m
 * @throws JSONException
 */
private static List<Response> toResponses(JSONObject jsonTask) throws JSONException {
    try {
        JSONArray jsonArray = jsonTask.getJSONArray("responses");
        List<Response> responses = new ArrayList<Response>();
        String type = jsonTask.getString("type");

        ResponseFactory respFactory;

        if (type.equals(TextResponse.class.toString())) {
            respFactory = new TextResponseFactory();
        } else if (type.equals(PictureResponse.class.toString())) {
            respFactory = new PictureResponseFactory();
        } else {
            throw new UnsupportedOperationException("Not implemented");
        }

        for (int i = 0; i < jsonArray.length(); i++) {

            Response resp = respFactory.createResponse(jsonArray.getJSONObject(i).getString("annotation"),
                    jsonArray.getJSONObject(i).getString("content"));
            resp.setTimestamp(new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy")
                    .parse(jsonArray.getJSONObject(i).getString("timestamp")));
            responses.add(resp);

        }

        return responses;
    } catch (ParseException e) {
        System.err.println("Could not parse date");
        e.printStackTrace();
    }
    return null;
}

From source file:com.popcorntime.apps.remote.utils.Utils.java

public static Date string2Date(String sd, String formato) {
    //formato = "yyyy-MM-dd'T'HH:mm:ss'Z'";
    //"Thu Jul 11 12:40:18 GMT-03:00 2013"
    //"EE MMM dd HH:mm:ss z YYYY"
    SimpleDateFormat format = new SimpleDateFormat(formato);
    try {/*from   w  w  w.jav a  2  s  .  c o  m*/
        Date date = (Date) format.parse(sd);
        return date;
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}

From source file:cn.ipanel.apps.portalBackOffice.util.CommonsFiend.java

public static Date stringToTime(String timeStr) {
    Date date = new Date();
    SimpleDateFormat apf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {// w w w  . j  a  va2  s. c  o  m
        date = apf.parse(timeStr);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date;
}

From source file:cn.ipanel.apps.portalBackOffice.util.CommonsFiend.java

public static Date stringToTime(String timeStr, String formatString) {
    Date date = new Date();
    SimpleDateFormat apf = new SimpleDateFormat(formatString);
    try {//from ww  w  . j  ava  2 s .c  o  m
        date = apf.parse(timeStr);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date;
}

From source file:cn.ipanel.apps.portalBackOffice.util.CommonsFiend.java

public static String next59Secends(String beginTime) {
    Date begin = new Date();
    try {/*from w  w  w . j a  va 2s  .c o m*/
        begin = new SimpleDateFormat(Defines.FORMAT_TIME_STRING).parse(beginTime);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    long nextMinute = begin.getTime() + 59000;
    return DateFormatUtils.format(nextMinute, Defines.FORMAT_TIME_STRING);
}

From source file:cn.ipanel.apps.portalBackOffice.util.CommonsFiend.java

public static Date stringToDate(String timeStr) {
    Date date = new Date();
    SimpleDateFormat apf = new SimpleDateFormat("yyyy-MM-dd");
    try {//from   w ww .j  a v a2  s  . co m
        date = apf.parse(timeStr);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date;

}