Questions tagged [android-dateutils]
51 questions
16
votes
4 answers
how to convert a date dd / mm / yyyy to yyyy-MM-dd HH:mm:ss Android
How can I convert a date in dd / mm / yyyy to a format that supports sqlite yyyy-MM-dd'T'HH: mm: ss
for example:
public static String convertStringToData(String stringData)
throws ParseException {
SimpleDateFormat sdf = new…

Douglas Mesquita
- 860
- 1
- 13
- 30
11
votes
3 answers
Change String date format and set into TextView in Android?
I want to change my date format that is in as
String date ="29/07/13";
But it is showing me the error of *Unparseable date: "29/07/2013" (at offset 2)*
I want to get date in this format 29 Jul 2013.
Here is my code that i am using to change the…

Developer
- 6,292
- 19
- 55
- 115
9
votes
0 answers
Android DateUtils flags explained
I am using getRelativeTimeSpanString (long time, long now, long minResolution, int flags) to calculate a relative date. The docs say that flags is "a bit mask of formatting options, such as FORMAT_NUMERIC_DATE or FORMAT_ABBREV_RELATIVE". However,…

karl
- 3,544
- 3
- 30
- 46
7
votes
5 answers
Formatting date & time according to user's locale & preferences with seconds
I am attempting to get a formatted date (year, month, date) and time (hour, minute, second) string according to the user's settings. This post in the Android Developers Google Group describes the precise problem I am having, but no one helped that…

plusCubed
- 113
- 2
- 7
5
votes
3 answers
Specifically using DateUtils, how do I format a numeric date with no year
I want to format a date string to not have a year (Ex: "1/4").
int flags = DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_NO_YEAR;
The above flags still append a year to the date (Ex: "1/4/2016"). How do I drop the year?

Andrew
- 20,756
- 32
- 99
- 177
5
votes
2 answers
customize android Date like twitter and instagram news feed
how can I customize the date format in an android development to be like that of twitter and instagram. What i have below my current code, but I don't like the format it produces like "11 minutes ago" or "34 minutes ago". I prefer the twitter format…

user3137376
- 1,527
- 2
- 19
- 29
4
votes
4 answers
Display relative date with custom format in Android
I want to translate a date to human readable format. I am using DateUtils. getRelativeDateTimeString, but this does not fit the criteria. The output I am getting looks like: 1 hour, 15 min. ago, etc.
I want to know if it is possible to change the…

Monika Bozhinova
- 294
- 3
- 16
3
votes
1 answer
How to update relative time in recyclerview?
I have a RecyclerView that displays items with a title, text and last edit time.
In the RecyclerView adapter's onBindViewHolder I use getRelativeTimeSpanString and compare the note object's time to current time:
@Override
public void…

Akres
- 126
- 2
- 16
3
votes
1 answer
How can I obtain a relative time string with a three-letter month?
I am using this code to get a relative time in my app:
DateUtils.getRelativeTimeSpanString(
mReferenceTime,
now,
DateUtils.MINUTE_IN_MILLIS,
DateUtils.FORMAT_ABBREV_RELATIVE
);
It is returning everything correctly,…

Ron Davis
- 346
- 8
- 28
3
votes
0 answers
DateUtils getRelativeTimeSpanString isn't returning time in "X seconds ago"
I am using the getRelativeTimeSpanString(...) to get time back in X seconds ago X hours ago etc.
However, when the difference between the two times is short - minutes or seconds, then it is returning in 10 hours instead of X minutes ago
Here is how…

birdy
- 9,286
- 24
- 107
- 171
3
votes
5 answers
How to get only the year from DateUtils
How do i get only the year part of a date using DateUtils ? I tried using
DateUtils.FORMAT_SHOW_YEAR
but this seems to return even the month and date.

lokoko
- 5,785
- 5
- 35
- 68
2
votes
2 answers
Android Java.DateUtils how to change date format?
I'm using the following:
DateUtils.getRelativeDateTimeString(context, created, DateUtils.MINUTE_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, DateUtils.FORMAT_ABBREV_MONTH);
It shows the date in a US format (MM.dd.yy). How can I change it to…

TOMKA
- 1,096
- 13
- 24
2
votes
0 answers
How to always get minutes from DateUtils.getRelativeTimeSpanString?
I need to display text like "2 hours, 31 minutes ago". I'm not attached to the format, it can be different. I wonder if I could do it with android.text.format.DateUtils.
So far I only partially succeeded with this:
val timePart =…

Jacek Kwiecień
- 12,397
- 20
- 85
- 157
2
votes
1 answer
How to show future date using DateUtils
I'm creating app. It's a news list where on every news I need to show date, e.g. 9 hours ago or 1 month ago and so on. Also I have future news, so I need also to show e.g. after 1 month. So I'm using DateUtils.getRelativeTimeSpanString() for this…

Hayk Mkrtchyan
- 2,835
- 3
- 19
- 61
2
votes
1 answer
getRelativeDateTimeString with day of week?
Is there any option to get getRelativeDateTimeString in day of week. Means if the date is within 7 days show it as Mon, 7:14am instead of 4 days ago, 7:14 am
DateUtils.getRelativeDateTimeString(context,
datewithTime.getTime(),…

Bincy Baby
- 3,941
- 5
- 36
- 62