List of utility methods to do Calendar Parse
Calendar | pars2Calender(String s) pars Calender Timestamp ts = Timestamp.valueOf(s);
return Timestamp2Calendar(ts);
|
Calendar | stringToCalendar(String date) string To Calendar Date myNewDate = null; Calendar calendar = Calendar.getInstance(); if (date == null || date.length() == 0) return null; SimpleDateFormat dateFormat = new SimpleDateFormat(SQL_DATE_FORMAT); try { myNewDate = dateFormat.parse(date); calendar.setTime(myNewDate); ... |
Calendar | convertStringToCalendar(String stringDate) convert String To Calendar SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy"); Date date = null; try { date = (Date) formatter.parse(stringDate); } catch (java.text.ParseException e) { Log.w(TAG, invalidDateFormat); Calendar calendar = Calendar.getInstance(); ... |
Calendar | getCalendarFromString(String time) get Calendar From String String[] timeParts = time.split(":"); int hour = Integer.parseInt(timeParts[0]); int minute = Integer.parseInt(timeParts[1]); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); return calendar; |
Calendar | getSelectCalendar(String dateStr, String pattern) get Select Calendar SimpleDateFormat formatter = new SimpleDateFormat(pattern); Date date = formatter.parse(dateStr); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar; |
Calendar | getDesignatedCalendar(String unformattedTime) get Designated Calendar unformattedTime = unformattedTime.replaceAll("(\\+[0-9+:]+)|Z", ""); String[] updateTimes = unformattedTime.substring(0, unformattedTime.length()).split("T"); String[] date = updateTimes[0].split("-"); String[] times = updateTimes[1].split(":"); int year = Integer.parseInt(date[0]); int month = Integer.parseInt(date[1]); int day = Integer.parseInt(date[2]); ... |