Android Utililty Methods Timestamp Get

List of utility methods to do Timestamp Get

Description

The list of methods to do Timestamp Get are organized into topic(s).

Method

intgetCurrentMonth(Timestamp t1)
get Current Month
Calendar calendar = new GregorianCalendar();
calendar.setTime(t1);
return calendar.get(Calendar.MONTH) + 1;
intgetCurrentWeek(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);
...
TimestampgetFirstOfMonth(Timestamp t1)
get First Of Month
Calendar a = new GregorianCalendar();
a.setTime(t1);
a.set(Calendar.DATE, 1);
return new Timestamp(a.getTimeInMillis());
TimestampgetFirstOfYear(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());
StringgetFriendlyTimeStamp()
Get date/time stamp with spaces replaced with underscores.
return new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
TimestampgetLastOfMonth(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());
TimestampgetLastOfYear(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());
StringgetRelativeTimeofTweet(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: "
...
TimestampgetTimestamp(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);
...
intgetWeekOfYear(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);