Questions tagged [android-date]

276 questions
2
votes
2 answers

Number of days between two dates in Android

I need to calculate the number of days between two dates (both dates are also included) entered by a user in EditText. I also need to check weather these days are coming or has already passed. How do I do it?
Anjali
  • 598
  • 2
  • 5
  • 15
2
votes
2 answers

Store date & time in SQLite database in Android

I am a bit confusing about how to store date $ time in SQLite database in Android. I need to store current date & time in my database table. so: 1) Which type to use when creating date/time column in my table? 2) How to get current date/time and…
Willy
  • 9,848
  • 22
  • 141
  • 284
2
votes
2 answers

Date Formatting is not working in android?

I have created a method to format date to "dd-MMM-yyyy" which is : public String formatDate(String day, String month, String year) { // Do something with the date chosen by the user SimpleDateFormat df = new…
Anshul
  • 7,914
  • 12
  • 42
  • 65
2
votes
2 answers

How to get device independent local date and time Android

My application is time dependent and I don't want change in device date and time affect my application, like if user deliberately set device date to any previous date . Is there any way to get current date and time when user is connected to mobile…
DCoder
  • 3,486
  • 7
  • 36
  • 68
2
votes
2 answers

Android System date changed event

I know this question has been asked many times but i am unable to find the right direction. I have registered BroadcastReceiver which I want to trigger when the Android System Date is changed automatically but its not firing. I have used the…
Mustansar Saeed
  • 2,730
  • 2
  • 22
  • 46
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
2
votes
4 answers

Parse some string date to another format

I have problem formating date. From : EEE, d MMM yyyy HH:mm:ss Z (example : Mon, 05 Jan 2014 15:10:00 +0200) To : dd/MMM/yyyy HH:mm (example : 05/01/2014 15:10) Here is what i tried : private String formatDate(String date) { SimpleDateFormat…
An-droid
  • 6,433
  • 9
  • 48
  • 93
2
votes
3 answers

Convert unix/epoch time to formatted date - unexpected date

Im trying to convert a timestamp to a human readable date and time. I tried: String dateSt = 1386580621268; Log.i("*****", "date st is = "+dateSt); long unixSeconds = Long.parseLong(dateSt); Log.i("*******", "unix seconds is = "+unixSeconds); Date…
DevC
  • 6,982
  • 9
  • 45
  • 80
2
votes
3 answers

I am trying to calculate difference between two dates in seconds. (Java/Android)

For someone else who might stumble here, the link refered to in this question gives misleading results My First Date: 1986-04-08. Current Date: 2013-11-28. Code: public long seconds(Date date){ String formattedDate = new…
Skynet
  • 7,820
  • 5
  • 44
  • 80
2
votes
1 answer

Time zone offset format +HH:mm versus +HHmm

I need to communicate with one application that is not implementing the full ISO 8601 and only accept the format +HH:mm for time zone offset. Android seems to only generate the format +HHmm (no ':' character in between hours and minutes) with the…
Luis
  • 11,978
  • 3
  • 27
  • 35
2
votes
4 answers

Android: Date Format in Month date year

My date in the application is displaying as 07/10/2011(dd/MM/yyyy)...I want date to be in the format Oct 7,2011 in android coding. Please help as am newbie to Android
AnnaSmith
  • 167
  • 1
  • 5
  • 11
1
vote
1 answer

UTC formatted string to UTC Date Object using SimpleDateFormat

I have a UTC formatted DateTime String and need this String to be converted to DATE Object without any Format change. Currently, when I try to convert it to a date Object it is returned as GMT formatted Date object as depicted in the image attached…
Muahmmad Tayyib
  • 689
  • 11
  • 28
1
vote
1 answer

How to convert date from yyyy/MM/dd to dd/MM/YYY the function below gives an error

How to convert date from yyyy/MM/dd to dd/MM/YYY the function below gives an error fun convertTime(date: String): String { val sdf = SimpleDateFormat("dd/MM/yyyy", Locale("pt", "BR")) sdf.isLenient = false val d: Date =…
Rafael Souza
  • 1,143
  • 2
  • 13
  • 29
1
vote
2 answers

How to generate localized datetime from "20201023T200457Z" and from "EEE MMM dd HH:mm:ss zzz yyyy"?

I have this start datetime: "20201023T200457Z" (it seem to be UTC0000) how can I convert/generate it with this "yyyyMMdd HH:mm:ss" pattern in local time on a mobile? I get this result: Fri Oct 23 20:04:57 GMT+02:00 2020 with this code: …
froniq
  • 105
  • 1
  • 8
1
vote
2 answers

How to combine two date and times into one date and time?

I have two dates with time values. I need to combine date from one and time from another and make third date and time of those. Here is the JSON: "block_times": [ { "id": 63672, "name": "One hour blocked time", "all_day":…
Zookey
  • 2,637
  • 13
  • 46
  • 80