0

How i do with my database date = 1456201899566(getTimeInMillis) and i want to make elapsed time from now with joda time. Thankyou and sorry for my bad english

1 Answers1

0

you can use PeriodFormatter .Source from here

 Date mydate = new Date(TimeInMillis);//TimeInMillis is your value from database
 DateTime mystartDate = new DateTime(mydate);

 //DateTime mystartDate = new DateTime(1978, 3, 26, 12, 35, 0, 0);
 DateTime now = new DateTime();
 Period period = new Period(mystartDate , now);

 PeriodFormatter formatter = new PeriodFormatterBuilder()
.appendSeconds().appendSuffix(" seconds ago\n")
.appendMinutes().appendSuffix(" minutes ago\n")
.appendHours().appendSuffix(" hours ago\n")
.appendDays().appendSuffix(" days ago\n")
.appendWeeks().appendSuffix(" weeks ago\n")
.appendMonths().appendSuffix(" months ago\n")
.appendYears().appendSuffix(" years ago\n")
.printZeroNever()
.toFormatter();

String elapsed = formatter.print(period);
Community
  • 1
  • 1
sasikumar
  • 12,540
  • 3
  • 28
  • 48
  • DateTime mystartDate = new DateTime(1978, 3, 26, 12, 35, 0, 0); <- i want to change this with my date data (1456201899566) from my database. How i do this? – Dio E Pratama Feb 23 '16 at 06:22