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:uk.bl.wa.indexer.WARCIndexer.java

/**
 * Returns a Java Date object representing the crawled date.
 * /*from ww w.jav a 2  s .  c om*/
 * @param timestamp
 * @return
 */
public static Date getWaybackDate(String timestamp) {
    Date date = new Date();
    try {
        if (timestamp.length() == 12) {
            date = ArchiveUtils.parse12DigitDate(timestamp);
        } else if (timestamp.length() == 14) {
            date = ArchiveUtils.parse14DigitDate(timestamp);
        } else if (timestamp.length() == 16) {
            date = ArchiveUtils.parse17DigitDate(timestamp + "0");
        } else if (timestamp.length() >= 17) {
            date = ArchiveUtils.parse17DigitDate(timestamp.substring(0, 17));
        }
    } catch (ParseException p) {
        p.printStackTrace();
    }
    return date;
}

From source file:com.wkb.core.util.IdcardUtils.java

/**
 * ??/*from   w  w  w  .  j a v  a2s.c o  m*/
 * 
 * @param idCard
 *            ??
 * @param minAge
 *            ?
 * @param minType
 *            ???145
 * @param maxAge
 *            
 * @param maxType
 *            ??145
 * @return ?
 */
public static boolean valiAge(String idCard, int minAge, byte minType, int maxAge, byte maxType) {
    //??
    if (!validateCard(idCard))
        return false;

    if (idCard.length() == CHINA_ID_MIN_LENGTH) {
        idCard = conver15CardTo18(idCard);
    }
    //?
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    //?
    Calendar birthCal = Calendar.getInstance();
    String birth = idCard.substring(6, 14);
    Date birthDate = null;
    try {
        birthDate = sdf.parse(birth);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    birthCal.setTime(birthDate);
    if (Constant.COMMON.DAY == minType) {

        birthCal.add(Calendar.DATE, minAge);
    } else if (Constant.COMMON.MONTH == minType) {

        birthCal.add(Calendar.MONTH, minAge);
    } else {
        //
        birthCal.add(Calendar.YEAR, minAge);
    }

    if (cal.before(birthCal)) {
        return false;
    }
    //maxAge0?
    if (maxAge == 0) {
        return true;
    }
    birthCal.setTime(birthDate);
    if (Constant.COMMON.DAY == maxType) {

        birthCal.add(Calendar.DATE, maxAge + 1);
    } else if (Constant.COMMON.MONTH == maxType) {

        birthCal.add(Calendar.MONTH, maxAge + 1);
    } else {
        //
        birthCal.add(Calendar.YEAR, maxAge + 1);
    }
    if (!cal.before(birthCal))
        return false;

    return true;
}

From source file:com.wbtech.ums.UmsAgent.java

private static void isCreateNewSessionID(Context context) {
    // TODO Auto-generated method stub
    long currenttime = System.currentTimeMillis();

    SharedPreferences preferences = context.getSharedPreferences("UMS_session_ID_savetime",
            Context.MODE_PRIVATE);
    long session_save_time = preferences.getLong("session_save_time", currenttime);
    if (currenttime - session_save_time > UmsConstants.kContinueSessionMillis) {
        try {/*from w w w .ja  va  2 s.  c  om*/
            generateSeesion(context);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

From source file:com.microsoft.projectoxford.face.samples.helper.StorageHelper.java

public static String getPersonName(String personId, String personGroupId, Context context) {

    ParseObject result;/*from   w  w  w .  j a  va 2 s  .co m*/

    ParseQuery<ParseObject> query = ParseQuery.getQuery("Student");
    query.whereEqualTo("personId", personId);
    String studentName = "";
    try {
        result = (ParseObject) (query.getFirst());
        studentName = result.get("studentName").toString();

    } catch (com.parse.ParseException e) {
        e.printStackTrace();
    }
    return studentName;

}

From source file:com.microsoft.projectoxford.face.samples.helper.StorageHelper.java

public static void deletePersonGroups(String personGroupIdToDelete, Context context) {

    ArrayList<ParseObject> objects = new ArrayList<>();
    int i = 0;/*from w ww  .ja v a2 s.c om*/

    //remove all list attendance -
    deleteAllList(personGroupIdToDelete, context);

    ParseQuery<ParseObject> query = ParseQuery.getQuery("Course");
    query.whereEqualTo("CourseId", personGroupIdToDelete);
    try {
        ParseObject courseResult = ((ParseObject) query.getFirst());
        courseResult.deleteInBackground();
    } catch (com.parse.ParseException e) {
        e.printStackTrace();
    }

}

From source file:com.microsoft.projectoxford.face.samples.helper.StorageHelper.java

public static ArrayList getAllListAttendance(String lectureName, String course, String code) {
    ArrayList<ParseObject> lisetOfAttendace = new ArrayList();
    ParseQuery<ParseObject> query = ParseQuery.getQuery("List");
    query.whereEqualTo("LectureName", lectureName);
    query.whereEqualTo("Course", course);
    query.whereEqualTo("Code", code);
    JSONArray arr;/*from w  w  w. java2  s .  co m*/
    String studentList = "";
    try {
        lisetOfAttendace = (ArrayList<ParseObject>) (query.find());

    } catch (com.parse.ParseException e) {
        e.printStackTrace();
    }
    ArrayList<String> listDates = new ArrayList<>();
    for (ParseObject date : lisetOfAttendace) {
        Object s = date.get("Date");
        if (s != null) {
            listDates.add(date.get("Date").toString());
        }
    }

    return listDates;
}

From source file:com.microsoft.projectoxford.face.samples.helper.StorageHelper.java

public static boolean createPerson(String personName, String cv, String personId, String personGroupId,
        String courseName, String code, Context context) {

    ParseQuery<ParseObject> query = ParseQuery.getQuery("Student");
    query.whereEqualTo("personId", personId);

    try {/*from   ww w.  j av a 2s  .  c  o m*/
        if (query.count() == 0) {

            if (checIfStudenExistInCourse(context, personGroupId, cv) != null)
                return false;
            ParseObject Student = new ParseObject("Student");
            Student.put("studentName", personName);
            Student.put("CV", cv);
            Student.put("faces", "{}");
            Student.put("personId", personId);
            Student.saveInBackground();
            if (!updateCourse(personGroupId, courseName, code, cv, personName, context))
                return false;
        }
    } catch (com.parse.ParseException e) {
        e.printStackTrace();
    }
    return true;
}

From source file:com.microsoft.projectoxford.face.samples.helper.StorageHelper.java

public static ArrayList<String> getAllStudentByCourse(String courseId, Context context) {

    ArrayList<String> listOfStudent = new ArrayList<>();
    ParseObject results;/*from  ww w. ja  v a  2  s  .com*/

    ParseQuery<ParseObject> query = ParseQuery.getQuery("Course");
    query.whereEqualTo("CourseId", courseId);
    String studentList;
    try {
        results = (ParseObject) (query.getFirst());

        JSONArray arr = new JSONArray(results.getString("studentList"));

        // ArrayList<String> cvList = new ArrayList<>();
        for (int i = 0; i < arr.length(); i++) {
            String cv = arr.getJSONObject(i).getString("cv");
            String name = arr.getJSONObject(i).getString("name");
            listOfStudent.add(name + "," + cv);
        }

    } catch (com.parse.ParseException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return listOfStudent;
}

From source file:com.microsoft.projectoxford.face.samples.helper.StorageHelper.java

public static ArrayList getAllListAttendanceByid(String lectureName, String course, String code, String date) {
    ArrayList<String> listOfStudents = new ArrayList<>();
    ParseQuery<ParseObject> query = ParseQuery.getQuery("List");
    query.whereEqualTo("LectureName", lectureName);
    query.whereEqualTo("Course", course);
    query.whereEqualTo("Code", code);
    query.whereEqualTo("Date", date);
    JSONArray arr;//  ww  w.ja v  a  2s  .c o m
    String studentList = "";

    try {
        ParseObject courseResult = ((ParseObject) query.getFirst());
        studentList = courseResult.getString("Names");
        if (!studentList.equals("{}")) {
            arr = new JSONArray(studentList);
        } else {
            arr = new JSONArray();
        }
        for (int i = 0; i < arr.length(); i++) {
            listOfStudents
                    .add((arr.getJSONObject(i).getString("name") + "," + arr.getJSONObject(i).getString("cv")));
        }

    } catch (com.parse.ParseException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }

    return listOfStudents;
}

From source file:com.microsoft.projectoxford.face.samples.helper.StorageHelper.java

public static ArrayList<String> runQuery(String from, String to, String courseId) {

    ArrayList<ParseObject> listTrainings = new ArrayList<>();
    ArrayList<String> list = new ArrayList<>();
    ParseQuery<ParseObject> query = ParseQuery.getQuery("List");

    query.whereEqualTo("Code", courseId);

    try {/*  w  w  w.j ava 2  s  .  co m*/
        listTrainings = (ArrayList<ParseObject>) (query.find());
    } catch (com.parse.ParseException e) {
        e.printStackTrace();
    }
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    Date date, toDate, fromDate;
    for (ParseObject course : listTrainings) {
        try {
            date = sdf.parse(course.get("Date").toString());
            toDate = sdf.parse(to);
            fromDate = sdf.parse(from);
            if ((date.after(fromDate) && toDate.after(date)) || date.equals(fromDate) || date.equals(toDate)) {
                list.add(course.get("Names").toString());
            }

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

    }

    return list;
}