List of utility methods to do Timestamp Get
int | getCurrentMonth(Timestamp t1) get Current Month Calendar calendar = new GregorianCalendar(); calendar.setTime(t1); return calendar.get(Calendar.MONTH) + 1; |
int | getCurrentWeek(Timestamp t1) get Current Week Calendar cal; if (t1 == null) { cal = Calendar.getInstance(); } else { cal = new GregorianCalendar(); cal.setTime(t1); return cal.get(Calendar.WEEK_OF_YEAR); ... |
Timestamp | getFirstOfMonth(Timestamp t1) get First Of Month Calendar a = new GregorianCalendar(); a.setTime(t1); a.set(Calendar.DATE, 1); return new Timestamp(a.getTimeInMillis()); |
Timestamp | getFirstOfYear(Timestamp t1) get First Of Year Calendar a = new GregorianCalendar(); a.setTime(t1); a.set(Calendar.MONTH, 0); a.set(Calendar.DATE, 1); return new Timestamp(a.getTimeInMillis()); |
String | getFriendlyTimeStamp() Get date/time stamp with spaces replaced with underscores. return new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); |
Timestamp | getLastOfMonth(Timestamp t1) get Last Of Month Calendar a = new GregorianCalendar(); a.setTime(t1); a.set(Calendar.DATE, 1); a.roll(Calendar.DATE, -1); return new Timestamp(a.getTimeInMillis()); |
Timestamp | getLastOfYear(Timestamp t1) get Last Of Year Calendar a = new GregorianCalendar(); a.setTime(t1); a.set(Calendar.MONTH, 11); a.set(Calendar.DATE, 1); a.roll(Calendar.DATE, -1); return new Timestamp(a.getTimeInMillis()); |
String | getRelativeTimeofTweet(String timeStamp) Return an absolute timestamp such as "49 seconds ago" final SimpleDateFormat sdf = new SimpleDateFormat( PARSE_TIMESTAMP_FORMAT, Locale.ENGLISH); String relativeTime = ""; try { long dateInMillis = sdf.parse(timeStamp).getTime(); relativeTime = getRelativeTimeAgo(dateInMillis); } catch (ParseException e) { Log.d("info", "Couldn't parse relative timestamp for: " ... |
Timestamp | getTimestamp(Timestamp timestamp, int day, int hour, int minute) get Timestamp Calendar calendar = new GregorianCalendar(); if (timestamp != null) { calendar.setTimeInMillis(timestamp.getTime()); } else { calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, day); calendar.set(Calendar.HOUR, hour); ... |
int | getWeekOfYear(Calendar cal, Timestamp ts) get Week Of Year if (cal == null) { cal = Calendar.getInstance(); cal.setTimeInMillis(ts.getTime()); return cal.get(Calendar.WEEK_OF_YEAR); |