Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Take A QuizChallenge yourself and boost your learning! Start the quiz now to earn credits.
Take A QuizUnlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Take A QuizPlease log in to access this content. You will be redirected to the login page shortly.
LoginCourse Queries Syllabus Queries 3 years ago
User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.
With System.currentTimeMillis(); you get the Milliseconds they have passed since 1/1/1970 as long.
So what u wand we can achieve with 2 more custom functions in your adapter.
The first one take ur date and time and convert it to miliseconds.
private long millisFromDateAndTime(String date, String time){
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMMM-yyyy");
SimpleDateFormat timeFormat = new SimpleDateFormat("kk:mm:ss");
try
{
Date mDate = dateFormat.parse(date);
Date mTime = timeFormat.parse(time);
long dateInMilliseconds = mDate.getTime();
long timeInMilliseconds = mTime.getTime();
return timeInMilliseconds + dateInMilliseconds;
}
catch (ParseException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return 0;
}
No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Please log in to access this content. You will be redirected to the login page shortly.
Login
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.
Your experience on this site will be improved by allowing cookies. Read Cookie Policy
Your experience on this site will be improved by allowing cookies. Read Cookie Policy
manpreet
Best Answer
3 years ago
I am new to in firebase and android also. In my app students can share his question and answer about syllabus. For this i set the time time and date string in firebase database and by the POJO class i retrieve the date and time in String format like Date: 06-April-2019 and time:01:38:24. Till now i used setText in TextView by model.getTime and model.getDate. So this like be a update(TextView) 06-April-2019 01:38:24 now i want to chnage it by Timeago like minute ago, hour ago, day ago, month ago, year ago
Sorry for bad english. and thanx in advance