List of utility methods to do String to Time
Date[] | getMReportTime(String time) get M Report Time SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM"); Date date = dateFormat.parse(time); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) + 1); calendar.set(Calendar.DAY_OF_MONTH, 0); Date[] dates = new Date[2]; dates[1] = calendar.getTime(); ... |
GregorianCalendar | getSignTime(final String stStr) get Sign Time if (stStr == null) { return new GregorianCalendar(); Date date; final SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd:HH:mm:ss"); try { date = formatter.parse(stStr); } catch (final Exception e) { ... |
String | getStringWithTime(String str) get String With Time DateFormat dateFormat = DateFormat.getTimeInstance(); return "(" + dateFormat.format(new Date()) + ") " + str; |
String | getSystemTime(String pattern) Gets the system time. long secs = System.currentTimeMillis(); SimpleDateFormat sdf = new SimpleDateFormat(pattern); Date date = new Date(secs); return sdf.format(date); |
Date | getTime(String date) get Time SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.parse(date); |
long | getTime(String date, String pattern) get Time try { return parseDate(date, pattern).getTime(); } catch (ParseException e) { e.printStackTrace(); return 0; |
long | getTime(String dateTimeString) get Time long time = 0; try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = sdf.parse(dateTimeString); time = date.getTime(); } catch (Exception e) { e.printStackTrace(); time = 0; ... |
String | getTime(String file) get Time return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(new File(file).lastModified())); |
String | getTime(String parrten) get Time String timestr; if (parrten == null || parrten.equals("")) { parrten = "yyyyMMddHHmmss"; java.text.SimpleDateFormat sdf = new SimpleDateFormat(parrten); java.util.Date cday = new java.util.Date(); timestr = sdf.format(cday); return timestr; ... |
String | getTime(String pattern) get Time return new SimpleDateFormat(pattern).format(new Date()); |