Android Utililty Methods Date to Timestamp Convert

List of utility methods to do Date to Timestamp Convert

Description

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

Method

TimestampDate2Timestamp(Date d)
Date Timestamp
return new Timestamp(d.getTime());
StringconvertToTimeStamp(Date date)
Convert date to short time string
return convertToTimeStamp(date, true);
StringconvertToTimeStamp(Date date, boolean showSeconds)
Convert date to short time string
Calendar c = Calendar.getInstance();
c.setTime(date);
return convertToTimeStamp(c, showSeconds);
longunixTimestampFromDate(final Date date)
unix Timestamp From Date
final Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal.getTimeInMillis() / 1000;
StringgetAccurateDate()
get Accurate Date
SimpleDateFormat fromat = new SimpleDateFormat("yyyyMMddHHmm");
Calendar c = Calendar.getInstance();
c.get(Calendar.YEAR);
c.get(Calendar.MONTH + 1);
c.get(Calendar.DAY_OF_MONTH);
c.get(Calendar.HOUR_OF_DAY);
c.get(Calendar.MINUTE);
String time = fromat.format(c.getInstance().getTime());
...
StringgetAccurateDate(Date date)
get Accurate Date
String result = AccurateTimeFormat.format(date);
return result;
StringtoFullDate(Date date)
to Full Date
synchronized (DATE_FORMAT_FULL) {
    return DATE_FORMAT_FULL.format(date);