Questions tagged [android-date]
276 questions
11
votes
4 answers
How can i get current date and time in android and store it into string
Currently i am using the code below:
String currentDateTimeString = DateFormat.getDateTimeInstance()
.format(new Date());
From this i am getting the output in the following format -
Jun 5, 2015 1:15:29 PM
But now i want…
user3997016
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
10
votes
4 answers
Android notification at specific date
I have to create an app in which I must set a date and at that specific date at 9 O'clock, I must give a notification. What is the simplest method of doing this? I want the app to work even when the app gets killed anyway. Is AlarmManager a…

Buze
- 129
- 1
- 1
- 6
10
votes
4 answers
java.text.ParseException: Unparseable date: "2014-06-04" (at offset 5)
I want to parse the date into a desired format but i am receiving an exception every time.
i know it is easy to implement but i am facing some problem don't know where exactly.:
Exception: java.text.ParseException: Unparseable date: "2014-06-04" (at…

Anchit Mittal
- 3,412
- 4
- 28
- 48
9
votes
0 answers
How to test date/time related functionality in Android?
I've been wondering how one is supposed to properly test functionality that relies on date or time changes with Android. Lets say I have events that need to be processed on the first of every month and the result of this processing depends on the…

theV0ID
- 4,172
- 9
- 35
- 56
9
votes
1 answer
Unexpected side effects when parsing dates in Android
In various Android projects, I use the following static function to parse dates such as 1900-12-31. Of course, this function should be deterministic - but it turns out it is not. Why?
Normally, it parses the date 2010-10-30, for example, to the…

caw
- 30,999
- 61
- 181
- 291
8
votes
4 answers
Android DatePicker Date Limiting
I am using DatePicket in my activity ,
I want to limit the date picked by user to todays date.
They should not able to select date greater than todays date.
thank you.

Ganapathy C
- 5,989
- 5
- 42
- 75
6
votes
3 answers
Get date , month and year from particular date
I want to get the date , month and year from the particular date.
I have used below code :
String dob = "01/08/1990";
int month = 0, dd = 0, yer = 0;
try {
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
…
user3997016
6
votes
2 answers
Android DateFormat for AM/PM differs between devices
I am formatting dates like this:
public static String toFormattedDate(@NonNull Time time, String toFormat) {
mDateFormat = new SimpleDateFormat(toFormat);
Date date = new Date();
date.setTime(time.toMillis(true));
…

Dale Julian
- 1,560
- 18
- 35
6
votes
7 answers
How do I display the calendar date on the top of chat messages?
I am working on a chat application but I am struggling to figure out how to display the calendar date on the top of chat messages; for example, something like this:
Another image with timestamps:
As you see in the example, the date is displayed on…
user2386226
6
votes
0 answers
UnknownFormatConversionException in getRelativeTimeSpanString for local BR
In my app there is a timestamp string that is created like this:
public String getTimestamp(Date when) {
long now = System.currentTimeMillis();
long past = when.getTime();
return DateUtils.getRelativeTimeSpanString(
past,
…

thepoosh
- 12,497
- 15
- 73
- 132
6
votes
2 answers
What is the difference between SimpleDateFormat and android.text.format.DateFormat?
From reading about them I understand that the android class is a utility class made for convenience only, and provide nothing that SimpleDateFormat doesn't provide. Is there any significance to the android class? Is it better practice to use it (if…
user1545072
5
votes
2 answers
How to Compare system date with mydate in android 2.1?
in my Android application, i am taking date and time from database. but i am not able to get the date in the "Date" Format from the database into my application, the date is in string format, so i am not able to compare the system date to database…
user674427
5
votes
3 answers
Android get actual time ( When internet is off and device time is incorrect)
As per question stated I need actual time. For example in my app I have to show a specific pop up to all the users at 8 AM national time. App runs in a specific country. What if there device time is incorrect ? I can get the time by an api . What if…

Nouman Ghaffar
- 3,780
- 1
- 29
- 37
5
votes
1 answer
What is the correct way to use the android.text.format.DateFormat.format method
I was reading the documentation for the android.text.format.DateFormat class on the Android developers website (located at http://developer.android.com/reference/android/text/format/DateFormat.html) in order to learn more about it. Specifically I am…

xBawbx
- 53
- 3