Questions tagged [android-date]
The android-date tag has no usage guidance.
276
questions
0
votes
1
answer
86
views
Get week range of current month in Android
I would like to show the week range in the MPAndroidChart Graph. For example in February month I would like to show the xAxis label value like 1-4, 5-11, 12- 18, 19-25, 26-28. Here 1-4 comes from the ...
0
votes
1
answer
133
views
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 ...
0
votes
2
answers
158
views
Calendar.DAY_OF_WEEK is returning wrong week?
Funny thing is that this Calendar is returning first day of the week as next Sunday which is completely illogical.
So I made index conversion function to sort days.
It worked for January, but as soon ...
0
votes
1
answer
461
views
How to operate on days in Kotlin?
I can get the current time like System.currentTimeInMillis(). But I really don't need this granularity in the millisecond range. A type which gets me a rough day date like 22.11.2021 is enough for my ...
1
vote
1
answer
2k
views
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", ...
0
votes
1
answer
114
views
How to use this UserDao with Date?
The app i'm trying to do is based retrieving current day, week and month data from room database, so my entity only contains id and date,
but in an older asked question there was an answer like this:
...
0
votes
1
answer
700
views
How to convert UTC time to user time zone?
I am getting UTC time from the server in 2021-06-20T09:56:05.697Z format. I want to format it to user time zone and I tried the below code. But it returns
java.text.ParseException: Unparseable date: &...
0
votes
1
answer
134
views
How can I change my date format using org.joda.time.LocalDate in android studio?
Basically, I want to get the date of Monday from the current day of the week.
eg: today is Tuesday and I want a Monday date, I'll get that required date from the following code lines:
val now = ...
0
votes
1
answer
623
views
YYYY date format returns 2021 on one device and 2020 on other device [duplicate]
I am trying to format the date using the below code.
2021-01-02 returns JANUARY 2020 in one device and JANUARY 2021 on another device. Why is it so?
formatDate(transactionItem.dateLabel, "yyyy-MM-...
0
votes
0
answers
410
views
Is it possible to create new file with some specific old date?
In my Android application I have a feature of renaming files. I have implemented this feature by creating a new file with new name on same path and then copying the content of original file to new ...
1
vote
2
answers
141
views
How to generate localized datetime from "20201023T200457Z" and from "EEE MMM dd HH:mm:ss zzz yyyy"? [duplicate]
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 ...
0
votes
2
answers
532
views
Midnight Time zone conversion
I'm trying to convert midnight of one timezone to midnight of another time zone. Kotlin pretty much made it easy for the conversion of time zones but it does not work the same way when converting date ...
0
votes
1
answer
85
views
How to get current date and store it to sqlite. After that plot it in graph in x-axis?
I want to get the current date and store it inside SQLite. After that, I want to use it in my graph.
Here is my code for storing data:
private View.OnClickListener onCalculate = new View....
0
votes
1
answer
2k
views
Efficient way to sort dates with their values in a JSON Array in Kotlin
In Android application development using Kotlin, which would be the efficient way to sort a JSON array which got objects having dates as property values.
I want to sort my response with date and pick ...
-1
votes
1
answer
162
views
cant subtract 2 timstamp long values
i'm trying to subtract two long(timestamp) but it kept crashing the application
heres the code
//converting timestamp to actual time;
val calendar = Calendar.getInstance(Locale.ENGLISH)
...
1
vote
2
answers
988
views
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"...
1
vote
1
answer
124
views
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: ...
0
votes
3
answers
2k
views
how to format string datetime in android [duplicate]
I get datetime data from soap web service to get string:2020-05-03T00:00:00.
Is there a way to split the string into dd / mm / yyyy, and if it is null then omitted?
I am using a substring(0,10) , but ...
-2
votes
1
answer
66
views
how to compare two date with my get date in android
In the below code, I want to compare a start date and an end date with my schedule date. I want to find within a week how many tasks are availables.
Suppose 16-03-2020 is the start date and 22-03-...
0
votes
1
answer
478
views
How to convert date to milliseconds with out timezone offset?
I what to convert selected date to milliseconds without timezone difference.
Below is my code.
String selectedDate=Jan 18, 2020;
SimpleDateFormat format = new SimpleDateFormat("MMM dd, yyyy", ...
3
votes
1
answer
220
views
How to store file with date into SD card?
In my application I want store a file into SD card.
What I would like is that when the app stores this file, add the now date as filename and for this I wrote the below codes.
But when users change ...
1
vote
2
answers
1k
views
Calculate age from birthday in milliseconds
I know that taking a different route to calculate the age is explained here already:
Calculate age from BirthDate
But I'm interested in knowing why my method isn't working. I'm getting today's date ...
0
votes
2
answers
299
views
not getting Dubai current time from calendar instance by using Dubai timezone [duplicate]
I have written a code to get Dubai current time. But i am getting the system current time in return
below is the code that i have been using
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(...
-3
votes
1
answer
719
views
System.currentTimeMillis() gets disturbed when user manually changes time
I am building application which is time sensitive i.e. some tasks need to be completed within certain time. There are multiple ways to get the time i.e. System.currentTimeMillis() and gpsLocation....
-1
votes
3
answers
351
views
Parse the String to Date and format
In the fragment I have a DatePickerDialog.OnDateSetListener. If I choose a Date, I send it to the presenter in the form of a String. Then I want to parse String to Date in Presenter and before save in ...
-3
votes
2
answers
2k
views
How to check if the date changed in android studio?
I would like to know if the date changed because I need to refresh a variable the next day.
Date currentTime = Calendar.getInstance().getTime();
date = (TextView) findViewById(R.id....
1
vote
3
answers
1k
views
How to display upcoming birthdays with java in android?
I am new in java programming and i am working for android apps development. I know the basics of java and i can understand the code. I need to know how can I calculate the upcoming birthday total days ...
1
vote
4
answers
340
views
Difference between two dates not working properly?
I am trying to find if selected date and today's date difference is equal to or greater than 18 years or not.
For getting today's date following is my code
private val simpleDateFormat = ...
0
votes
4
answers
135
views
How to calculate number of hours between current date and an String text date
I am getting a string from service, 2 Nov 2019 07:30 pm, the date is in United States Central Time.
Now i need to know how much time is remaining between current time and this date.
I am using ...
1
vote
1
answer
995
views
How do I convert epoch time to date and time zone is defined in offset in millisecond
I am parsing one api date related to the weather app.
Here I am getting time in epoch time I want to convert into Date time format.
I am getting sunrise time that is epoch time. It is 1569494827(input ...
20
votes
5
answers
79k
views
How to format in Kotlin date in string or timestamp to my preferred format?
I'm getting date data from weather API in two versions. The first one is just string like this: 2019-08-07 09:00:00 and like this: 1565209665. How do I change it to just the name of the day or day and ...
0
votes
2
answers
647
views
How to get week interval in between two dates in android?
Hi I am writing a code which can show the week interval between current time and login time,
I am adding one function by which I am saving login time.
public void setWeek() {
Date today = new ...
0
votes
1
answer
117
views
How can I set the maxDate on a calendar if I have a String? [duplicate]
How can I set the maximum date of a calendar using setMaxDate if I have the date with the format dd/mm/yyy?
I'm developing for Android.
0
votes
1
answer
247
views
CountdownTimer is not working as intended (wrong time)
I'm using CountdownTimer in my app to display remaining time until specific Date. But Date is only 2 hours from current time, but if I convert millisUntilFinished to hours, it says 9 hours. Date is in ...
1
vote
2
answers
1k
views
Percentage between two dates compared to today in android/java
How I can find percentage between two dates compared to today in android/java?
This question is based on this question.
I want to do something like this:
Calendar c = Calendar.getInstance();
...
1
vote
2
answers
4k
views
How do I abbreviate month to 3 characters?
I am trying to abbreviate month in date time to 3 characters, say if the month is May, it shows May, but if the month is june, it should show Jun, and september should show sep and so on.
I have ...
-1
votes
1
answer
102
views
How do I get the time an hour from now for my 12 hour time format in string?
I am planning to add an hour to the current time, which I have converted into a 12 hour format. Just not sure how to go about it. I want to keep mins the same, just want to add an hour, say the time ...
0
votes
1
answer
211
views
How do I hardcode a specific default time [ANDROID]?
I am setting some default hardcoded times. I am looking to hardcode 6pm as my default time. I have the code as follows:
Calendar mDate = Calendar.getInstance();
SimpleDateFormat mDateFormat = new ...
0
votes
0
answers
83
views
Unable to parse "April 10, 1999" to date [duplicate]
I have date in April 10, 1922 format, I want to convert this date to yyyy-MM-dd'T'HH:mm:ss'Z' format, but first i want to convert this string into date.
I created a pattern for it, to convert this ...
0
votes
2
answers
67
views
How do I compare whether my selected calendar endtime is earlier than selected calendar starttime on a 12 hour calendar time?
I am trying to cross check if my selected calendar endtime is earlier than my selected calendar starttime on a 12 hour time period.
Currently I am using 2 different attributes to store selected ...
-1
votes
2
answers
249
views
How do I convert my date string to a custom date format?
I am currently working on creating a custom date format such that it is supposed to show as "Monday, April 8, 2019 "
but whenever I pick from dialog and apply simple date format, it returns the date ...
1
vote
2
answers
197
views
Selecting some dates in Calendar while initializing it
I am using CalenderView in android. I have a list of predefined dates as ["2019-02-15","2019-02-16","2019-02-17"]. When Calender is initialized and shown on Activity/fragment i want this dates to be ...
0
votes
1
answer
148
views
date not updating in android app when left open overnight
I am having an issue with one of the apps I am working on. The app has a DatePickerDialog in it with a calendar icon in the ActionBar. I am setting it up like so...
MainActivity.java
//...
private ...
0
votes
1
answer
33
views
String to Date object in Android [duplicate]
I have two string values in one key for the date
Case 1 : date can be a string value ="2010-10-15T09:27:37Z"
Case 2 : and sometimes it can be a "20130526160000"
but I have only one function to ...
0
votes
2
answers
1k
views
How to show the next day's date from the selected date in the datepicker dialog in Android?
I am currently showing the today's date and day & as well as tomorrow's date and day in individual layouts while at the page load. But my requirement is that
1) Whatever the date I'm choosing ...
0
votes
0
answers
294
views
SimpleDateFormat parse doesn't work on Date in UTC format from database
I use Parse.com and each ParseObject has date column with Date type in UTC format.
I want to sort those object which I get from query by date. So I'm using SimpleDateFormat and Comparator to compare ...
0
votes
2
answers
2k
views
How to parse date from Datepicker in UTC format?
I want from user to pick a date and I want to set this date in ParseObject (I'm using Parse.com). Column in ParseObject is type Date and it is in same format as SimpleDateFormat below. But from ...
0
votes
1
answer
1k
views
Change in Calendar date by default [duplicate]
I am having a strange problem here in android project. I am trying to convert the date into other date and for that, I am calculating the days between two dates.
So, here is how I have implemented.
...
0
votes
4
answers
906
views
Get unix timestamp exactly 3 years from now
Using Android and Java 8, how can I get unix timestamps back in time?
E.g.
Exactly 3 years back from now
Exactly 2 months back from now
Exactly 1 day back from now
etc
I know I can get current ...
1
vote
1
answer
168
views
When changed locale app change type digits format of device
I am changing locale language app like bellow:
@Override
protected void attachBaseContext(Context newBase) {
String languageID = new SessionManager(newBase).getIdLanguage();
super....