Questions tagged [android-dateutils]
51 questions
2
votes
1 answer
Android: Is there a way to show "min" instead of "minute" with DateUtils
I'm using DateUtils to show the posted time. But is there a way to show:
"4 min ago" instead of "4 minutes ago"
CharSequence result = DateUtils.getRelativeTimeSpanString(timestamp, Currenttime,DateUtils.SECOND_IN_MILLIS);

Joris
- 119
- 9
2
votes
2 answers
How to display the exactly time from sensorevent.timestamp for Android?
I want to display the time which the first step was detected. But the app always shows Jan 01 1970. Would some one check what is wrong and how to change it? Here is my code:
public void run() {
SensorManager mSensorManager = (SensorManager)…

Yongyi Wu
- 21
- 1
- 1
2
votes
1 answer
How to describe duration in Android?
I'm writing small app and I need to write duration of sport event in i18n. Im using PrettyTime library for date, but when I attempt to use DateUtils or PrettyTime, I have issues..
For example I want to say that duration is 2 minutes. I need some way…

kurd
- 467
- 1
- 10
- 18
2
votes
2 answers
Putting Date from Parse.com to same type as System Date
I want to ask, how can I put Date from Parse.com (which is in format "Sat Mar 01 15:52:20 GMT+1:00 2014") to same Date type as the date and time in system. Second thing I want to ask is, how to get only for example "month:day:hour:minute:year" from…

marson
- 913
- 10
- 32
1
vote
1 answer
How to change the locale for date formatting on Android device?
I am trying to test that my Android app formats dates correctly according to locale. For example, I would expect it to show:
"Nov 07" in U.S. (what I see currently) versus "07 Nov" in U.K.
No matter what I do, the date on my device and all apps is…

user18208230
- 23
- 3
1
vote
0 answers
arabic digits are shown instead of English
I've a text view. in onCreate I set its text to be:
textView.setText(DateUtils.formatElapsedTime(162)) // 162 seconds
Because the app is in arabic, its date is written as: "٠٢:٤٢" while I would like to set it in ENGLISH.
How to show this number in…

Maor Cohen
- 936
- 2
- 18
- 33
1
vote
1 answer
DateTimeFormatter class exeception DateTimeParseException
I want to get next 3 months date from the enter date in android device.
for versions greater than oreo I tried to use DateTimeFormatter.
but I got this error "java.time.format.DateTimeParseException: Text '28/5/2020' could not be parsed at index…

Ankur Shinde
- 304
- 4
- 19
1
vote
1 answer
How to use TimeAgo format with firestore or realtime database?
I am using a Github Library to Display time in a TextView as the format like just now, yesterday, time ago... etc. It displays the time as I want. But the problem is that the time is not changing as it was just now at the moment of post-it remains…

Stackoverflower
- 292
- 4
- 17
1
vote
0 answers
How to change DateUtils.getRelativeTimeSpanString strings?
I'm trying to convert a date to relative date.
For example
12-03-2017 --> 2 years ago.
I'm using an android class which is "DateUtils.getRelativeTimeSpanString"
This class works just fine. But I have a little problem.
My app will serve in Turkish…

kaya
- 45
- 6
1
vote
3 answers
I can't import java.util.date in activity
In my project I need to to use current date and time. For this I'm importing java.util.Date.
This import is working fine few hours ago. But I have an error in R file ( r cannot resolve ) and this error is because of some xml mistake. When I…

Ehtasham Ali
- 75
- 1
- 8
1
vote
2 answers
Wrong 1st argument type. Found: 'com.example.sunshine.FetchData', required: 'android.content.Context'
I guess this question is more about understanding context and how to use it properly.
After having googled and "stackoverflowed" a lot I could not find the answer.
Problem:
when using DateUtils.formatDateTime I cannot use "this" as a context. The…

Hooni
- 354
- 1
- 4
- 13
1
vote
2 answers
How to increase elapsed time for getRelativeDateTimeString method, also how to month name for normal date
I have used getRelativeDateTimeString which is showing the maximum of 1 week elapsed time.
How to increase more than 1 week.
after the elapsed time it shows the normal date formatting like 11/14/2007, 8:20 AM, I want to show month name in a date…

Raj
- 946
- 12
- 16
1
vote
2 answers
DateUtils.formatDateRange() issues when formatting date range
In my app, I receive dates from a webservice in the form yyyy-MM-dd (e.g. 2016-03-05) and I need to format them as [abbreviated month] [date], e.g. Mar 5. Additionally, I have a start and end date and want to show them as a date range, unless both…

Karakuri
- 38,365
- 12
- 84
- 104
1
vote
2 answers
How to remove date from DatePicker toString method?
I have just started learning android through Android's big nerd ranch guide. I have written a simple program in android that let's user select a date. While printing the date using getDate().toString() method, I am also getting the Time. I want to…

Shubham Sharma
- 35
- 7
1
vote
1 answer
How to get real time date from server in android?
I have one android application which will show random Quotes everyday from application's
database, but when i change date in my android phone, i will get the future quotes. To stop this i need current date and time from server side ?
Is there any…

nirav kalola
- 1,220
- 13
- 17