List of utility methods to do Unix Date
String | escapeUnixChar(String strToEscape) escape Unix Char StringCharacterIterator charIter = new StringCharacterIterator(strToEscape); StringBuilder buf = new StringBuilder(); char ch = charIter.current(); while (ch != 65535) { if (ch == ';') buf.append("\\;"); else if (ch == '&') buf.append("\\&"); ... |
String | getDispTimeByUnixTime(long unixSec) get Disp Time By Unix Time SimpleDateFormat sdf = new SimpleDateFormat("yy/MM/dd HH:mm:ss"); return sdf.format(new Date(unixSec * 1000)); |
String | getUnixDate() get Unix Date Date now = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return formatter.format(now); |
String | getUnixDate(Date date) Get unix style date string. long dateTime = date.getTime(); if (dateTime < 0) { return "------------"; Calendar cal = new GregorianCalendar(); cal.setTime(date); String firstPart = MONTHS[cal.get(Calendar.MONTH)] + ' '; String dateStr = String.valueOf(cal.get(Calendar.DATE)); ... |
String | getUnixDate(long millis) Get unix style date string. if (millis < 0) { return "------------"; StringBuffer sb = new StringBuffer(16); Calendar cal = new GregorianCalendar(); cal.setTimeInMillis(millis); sb.append(MONTHS[cal.get(Calendar.MONTH)]); sb.append(' '); ... |
String | getUnixDate(String s) get Unix Date try { Date dte = dateFormatterRss.parse(s); return String.valueOf(dte.getTime() / 1000); } catch (Exception e) { return "00000000"; |
long | getUnixTime(String dateTime) get Unix Time Date date1 = null; Date date2 = null; try { date1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateTime); date2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("1970-01-01 08:00:00"); } catch (ParseException e) { e.printStackTrace(); long l = (date1.getTime() - date2.getTime()) / 1000; return l; |
String | getUnixTime2NoneTime(String longTime) get Unix Time None Time String fileseparator = System.getProperty("file.separator"); int len = longTime.length(); long ltime = 0; if (len > 13) { longTime = longTime.substring(0, 13); ltime = Long.parseLong(longTime); Date date = new Date(); ... |
Calendar | parseUnixDate(String paramName, String dateStr) Tries to parse unix date. Calendar day; try { day = Calendar.getInstance(); long ms = Long.parseLong(dateStr); day.setTimeInMillis(ms); } catch (Exception e) { throw new IllegalArgumentException("Unparsable \"" + paramName + "\". Must be UTC time in ms", e); return day; |
Map | stringUnixTime(String start, String end) string Unix Time try { HashMap<String, Long> strUnixTime = new HashMap<String, Long>(); String startTime = start.split("T")[1]; String endTime = end.split("T")[1]; int startIndex = timeToIndex(startTime); int endIndex = timeToIndex(endTime); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm"); dateFormat.setTimeZone(TimeZone.getTimeZone("America/New_York")); ... |