android - How to do time remaining with JAVA and SQL? -
i working on android based app , using java web services too. mean website built java too. here thing, new @ java programming , learning stuffs. have been searching create "time remaining" notification in android. deal don't know how use time/sql related class in java.
what want example, event happened on 1st july, 2015 @ 12:00 , available next 48 hours. so, want add expire time in database. don't want use "2015-07-12 06:47:39.154 " database, instead of want save milliseconds can subtract current time , can have few hours left etc. , in android app, want show snapchat. how can see photo cropped in circle during 24 hours.
i work on android stuff. thing looking when app communicates server, website respond in percentage of remaining time. if 36 hours remaining 75, if 30 65 or some, if 24 50 etc. so, can me how can use it? looking so, appreciated.
my actual time code in java,
//for timestamp long retrydate = system.currenttimemillis(); int sec = 604800; timestamp original = new timestamp(retrydate); calendar cal = calendar.getinstance(); cal.settimeinmillis(original.gettime()); cal.add(calendar.second, sec); timestamp later = new timestamp(cal.gettime().gettime());
try this,
long timeaftertwodays =(system.currenttimemillis() + 172800000); store in database. give exact time after 48 hours.
so when call database, this,
long timefromdb = //your saved time long currenttime = system.currenttimemillis(); int remainingtime = ((timefromdb - currenttime))/1728000; this give remaining time in percentage. hope answer helpful said appreciated. if face problem or error, let me know here. have tested , had couple tricks work. ;)
Comments
Post a Comment