Questions tagged [simpledateformat]

SimpleDateFormat is a concrete Java class for formatting and parsing dates and times in a locale-sensitive manner. It allows for formatting (date -> text), parsing (text -> date), and normalization.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
39 views

How to read date what I gave? [duplicate]

here, I gave date using SimpleDateFormat in this program. I want print them. But, it shows only null value. how to call exact date in displayBooked() method? import java.text.ParseException; import ...
Haris's user avatar
  • 1
1 vote
0 answers
94 views

Date Parse Exception in Android for input Mon, 11 Sep 2023 15:49:32 GMT

fun calculateAge(dateString: String): String { val dateFormat = SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z") dateFormat.timeZone = TimeZone.getTimeZone("GMT") ...
MARSH's user avatar
  • 105
0 votes
1 answer
78 views

SimpleDateFormat string parsing issue in a Specific Android Device [duplicate]

I have a released android app and a strange issue has cropped up with a specific device. On analysis of Crashlytics data, I found that the app is crashing for this particular user (and device) because ...
oTwo's user avatar
  • 185
0 votes
0 answers
54 views

Converting Server GMT date and time to User specified date and time zone with specified format, returning with Date datatype [duplicate]

I am trying to convert the Date received from Server to user specific date format (IST) and returning as Date datatype. Attached the sample code and result as below import java.text.SimpleDateFormat; ...
Prakash's user avatar
  • 630
0 votes
3 answers
123 views

SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); customize the timezone

I want to print the date with the char ":" in the middle of timezone, example : 2023-08-02T14:19:10+02:00 At the moment I am using this pattern: SimpleDateFormat("yyyy-MM-dd'T'HH:mm:...
monotor's user avatar
  • 107
0 votes
1 answer
83 views

Is this a bug in SimpleDateFormat, or a feature? [duplicate]

I recently changed... continents and temporarily forgot to signify July 27th 2023 in the European way, i.e "27/07/2023", and instead maintained the American - style literal "07/27/2023&...
Jason's user avatar
  • 2,525
-1 votes
2 answers
125 views

How to convert date from this format "dd/MMM/yyyy" to any other format with Java 17 version?

I am trying to convert date from this format "dd/MMM/yyyy" to "yyyyMMdd", for Java 1.8 version ,the code was working fine, my code is SimpleDateFormat inputFormat = new ...
user3608694's user avatar
0 votes
1 answer
61 views

SimpleDateFormat("MMM d, yyyy") returns Weekday Month day 00:00:00 EDT year [duplicate]

I have a String List [Apr 1, 2019, Aug 1, 2020, Feb 20, 2018] which i need to convert to Date format in the same pattern. When Im doing it with SimpleDateFormat("MMM d, yyyy") pattern Im ...
Gunel Hasan's user avatar
0 votes
2 answers
191 views

Cannot parse date containing GMT to Timestamp in Java (Unparseable date Issue)

I cannot convert the date containing GMT to timestamp in Java Here is the code shown below import java.sql.Timestamp; import java.text.ParseException; import java.text.SimpleDateFormat; import java....
S.N's user avatar
  • 2,183
0 votes
0 answers
47 views

Need alternative for toJavaDatePattern method from HsqlDateTime class from jar - hsqldb-2.3.1

Need alternative for toJavaDatePattern method which is available in HsqlDateTime class from jar - hsqldb-2.3.1. Method usage - Converts the given format to pattern acceptable by SimpleDateFormat. ...
Ragas's user avatar
  • 147
0 votes
1 answer
107 views

Why ParseException is not caught?

Why is ParseException not caught here? When I enter a date consisting of more than 4 digits it just accepts it, but it shouldn't as I set lenient to false. When I enter letters for the year I get ...
Ievgeniia Leleka's user avatar
-3 votes
2 answers
136 views

How to convert different date formats in JDK11 to dd-mm-yyyy format? [duplicate]

I have a use case where I have date in the following formats, 2023-05-09T05:55:07Z 2023-04-30 08-05-2023 2023-05-09 00:00:00 31-Dec-2021 Irrespective of the input format I have a requirement to ...
Diksha Goyal's user avatar
0 votes
1 answer
84 views

How to format a date inside a String with Java? [duplicate]

I have a String that receives the following date format (yyyy-MM-dd ...) "2023-03-13 12:00:02" and i need to change the format to the following (dd-MM-yyyy ...) "13-03-2023 12:00:02....
Root93's user avatar
  • 141
0 votes
4 answers
321 views

Converting UTC to Local Time with daylight saving in Java

I am trying to convert UTC time to local time, including daylight saving. Localtime (Stockholm), in summer, should be 2 hours ahead of UTC, but when I convert it in Java it only adds one hour. public ...
Pacmyc's user avatar
  • 23
-1 votes
1 answer
66 views

Why are months one less than the selected value when using DatePickerDialog in Kotlin?

I'm developing an Android app in Kotlin, and I'm using the DatePickerDialog to allow the user to select a date. However, I've noticed that when the user selects a month, the value passed to the ...
Anantashayana's user avatar
0 votes
2 answers
54 views

Converting time into number of seconds? [duplicate]

I am using simple date format to convert the following into number of seconds Input : 00:00:10.000 , 00:05:10.000, 01:00:23.000 Expected output : 10 seconds , 310 seconds , 3623 seconds Below is how I ...
WISHY's user avatar
  • 11.2k
1 vote
1 answer
64 views

SimpleDateFormat is giving wrong hours and seconds data

I'm using SimpleDateFormat to get the hours and seconds in this format "HH:MM a" for 2 dates in same function. The output printing is same for both of them and it is mostly of the first date....
PT15's user avatar
  • 13
-1 votes
2 answers
77 views

Parse string date Unparseable date java

I'm trying to parse a String date like :Mon Dec 28 15:18:16 2021 into some thing like this: yyyy-MM-dd HH:mm:ss z. This is my code. public void parseDate(String stringDate) throws ParseException { ...
rvicente's user avatar
0 votes
2 answers
94 views

How to convert a date into another date as a String in Java?

I want to convert a date format into another date format. For example, I have this String "05-Apr-23" and I want to convert it into this String "05/04/23". And I did this ...
elvis's user avatar
  • 990
-1 votes
3 answers
396 views

Convert Date to UTC DateTime

I have the date 2023-04-03 and wanted to convert it into UTC time with range (start and end of the day) 2023-04-03T00:00:00 -> 2023-04-02T18:30:00z 2023-04-03T24:00:00 -> 2023-04-03T18:30:00z ...
Anuj kumar's user avatar
1 vote
5 answers
134 views

Issue when comparing date with Java

I am encountering some issues right now when I compare two dates in Java. I want to check that a date is the same day on the next week that today. First, I am doing this: SimpleDateFormat sdf =...
Cucumberbatch's user avatar
0 votes
2 answers
89 views

Java SimpleDateFormat returns incorrect date [duplicate]

Im working with some dates in Java. Trying to parse some string date inputs to Date objects. This is done using SimpleDateFormat.parse(String date). When I use the SimpleDateFormat of "yyyyMMdd&...
Keham Makene's user avatar
-3 votes
1 answer
86 views

How to convert dd/MM/yyyy into dd/mm/yyyy in JavaScript? [closed]

I have a date field on which I am calling datepicker in the following format : $(function() { $('.dob').datepicker({ dateFormat: 'dd/MM/yyyy', }); }); When the user selects ...
Ananya's user avatar
  • 23
-4 votes
2 answers
570 views

Is there any other way to convert "timestamp = System.currentTimeMillis()" to normal date time, say for example "DD-MM-YYYY HH:MM:SS"

Actually we are using a "timestamp = System.currentTimeMillis()", which is an Epoch time! We are looking to convert the same to normal format ex: 15-03-2020 (dd-mm-yyyy). We are using: ...
Akshay Prakash's user avatar
0 votes
2 answers
51 views

The date obtained by sprigboot console is inconsistent with the date obtained by the browser

When I get a timestamp date data from the database, I convert it to the format I want through simpledateformat, and everything is normal here, and the date and time are correct when I test it with ...
黃奕翔's user avatar
-4 votes
1 answer
111 views

Convert PST date millis to UTC millis [closed]

In a data stream, I'm receiving date attribute values in milliseconds in Pacific timezone. Like for date = Wed Jan 18 2023 18:00:00 Pacific Time, I'm receiving milliseconds value as 1674064800000. It ...
sahillearner's user avatar
0 votes
0 answers
80 views

How to use SimpleDateFormat week number (w) and weekday (u) coherently?

I would like to set up a functionality for Google Sheets that provides a start and end day for a given week index number of the year. When using the Utilities.parseDate and Utilities.formatDate ...
tp43793's user avatar
0 votes
0 answers
45 views

Google Apps Script dateformat issue for ISO8601 timezone

I have to format date in a google Apps script but i have a mistake. In the oracle documentation (link in the google Apps script help )[https://docs.oracle.com/javase/7/docs/api/java/text/...
Bertrand BALDACH's user avatar
0 votes
1 answer
105 views

Convert Date string into another string with different format

I'm quite new to the Java and for the use case I would like to know how to convert String "2023-02-01" into "02012023" I had troubles understanding the correct usage of ...
Markus's user avatar
  • 3
-1 votes
1 answer
148 views

Why I am not able to parse 2013-03-10T02:59:59Z from PST in Java using parse method of java.text.SimpleDateFormat?

For certain input values though format and all things are correct, I am getting ParseException from SimpleDateFormat.parse(String input) method. I'm in a scenario where I need to convert time from ...
Risabh Gupta's user avatar
0 votes
2 answers
442 views

Formatting timestamp to Date format [duplicate]

I have a question. I need to convert and display the data from database which it's a timestamp to date format only. *the format is dd/MM/yyyy Currently I writng the code like this but the error says &...
Syafiza Surani's user avatar
0 votes
0 answers
76 views

Using GsonBuilder.setdateformat("dd-MM-yyyy HH:mm:ss") can I convert a date json Object to key value pair?

Currently I am using Gson to convert an object to json Custom Adapter public class MyDataMsgSerializer implements JsonSerializer<MyDataMsg>, JsonDeserializer<MyDataMsg>{ private ...
venky598's user avatar
0 votes
2 answers
100 views

How to print UTC or GMT using SimpleDateFormat? [duplicate]

I am trying to print a date in this format: 2023-01-11 09:25:52 UTC But when I use date format: yyyy-MM-dd HH:mm:ss Z I get: 2023-01-11 09:29:25 +0100 While searching by existing question in stack ...
Ricardo Machado's user avatar
4 votes
5 answers
269 views

How do I get the maximum date (in YYYYMM format) from an array of dates in java?

I want to find out the largest date from an array of dates in yyyyMM format. For example, suppose my arraylist of dates are: ["202210", "202211", "202212", "202301&...
user avatar
4 votes
2 answers
252 views

SimpleDateFormat succeeds or throws depending on year number

I'm working with legacy code that tries to parse dates that include an optional time component that's usually padded with zeroes, using the a format string ddMMyy that doesn't really match the input. ...
jqno's user avatar
  • 15.2k
1 vote
1 answer
70 views

Android convert numbers into date format

I am storing month and year in my android database. I want to fetch it and convert it to date format so that I can match it with current month and year present in array. Im fetching it through ...
Abm's user avatar
  • 271
0 votes
3 answers
3k views

How to change timezone of date android kotlin [HH:mm]

As input, I get a string like HH:mm, which is UTC. But I need to convert the time to +3 hours (i.e. UTC +3). For example, it was 12:30 - it became 15:30. I tried this code, but its not working :( fun ...
onesector's user avatar
  • 361
0 votes
1 answer
547 views

how to change T Z Format 2022-12-08T06:07:34.780Z (yyyy-MM-dd'T'HH:mm:ss.SSSZ) come to server but Display DD/MM/YYYY

2022-12-08T06:07:34.780Z 12-10-2022 only Utility.log_d("Date12343",orderlist.getCreatedAt()); /*Calendar c = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat(...
Vishal Rastogi's user avatar
-2 votes
1 answer
81 views

Error for formatting Cannot format given Object as a Date [duplicate]

I have this code: private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); Now, I try to format check some String data, final String ...
Arefe's user avatar
  • 11.3k
1 vote
0 answers
275 views

Unparseable date exception for the date format 2020-12-31T11:46:18.000+00:00 [duplicate]

How do i parse a date with the format 2020-12-31T11:46:18.000+00:00 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); Date startDate = sdf.parse("2020-12-31T11:...
Amit's user avatar
  • 255
0 votes
1 answer
72 views

Date is displaying in different time zone when parsing a string using SimpleDateFormat [duplicate]

public class ParseDate { public static final String DATE_FORMAT = "yyyy-MM-dd"; public static SimpleDateFormat DateFormatter = new SimpleDateFormat(DATE_FORMAT); public ...
Nag's user avatar
  • 3
0 votes
1 answer
727 views

How to convert a date with time zone offset to another format

I tried reading a lot about the date formatting with time zone, but it doesn't make sense to me. My DB shows this datetime: 2022-12-01 04:00:00.000 +08:00 My UI shows it as: Thu 01/12/2022 12:00 I ...
user12272269's user avatar
1 vote
0 answers
70 views

Android DateTimeFormatter - Time Conversion not working on samsung devices

I was working on Time conversion from One Locale to another (US to Swedish) in android using Java. It is working well on all the devices except Samsung devices. DateTimeFormatter parser = ...
Shobhith's user avatar
  • 505
0 votes
3 answers
191 views

Java date format different results

I am looking to understand why this code is giving me different results. I want to format 2022-10-12T00:00:00.000Z into yyyy-MM-dd format. Result when I run it online in Java IDE: 2022-10-12 But on ...
zerstoer's user avatar
2 votes
2 answers
183 views

SimpleDateFormat time conversion from US to Swedish doesn't work on real device but works on emulator

I am working on SimpleDatFormat on android. I tried to convert time from US locale to Swedish. It is working fine in emulator but when I tested it on Samsung devices it is not working. On rest of the ...
Shobhith's user avatar
  • 505
1 vote
2 answers
1k views

CheckMarx issue : Race condition format flaw

Checkmarx complains that "the file utilizes "format" that is accessed by other concurrent functionality in a way that is not thread-safe, which may result in a Race Condition over this ...
Deepak's user avatar
  • 47
-1 votes
2 answers
82 views

Strange behavior of SimpleDateFormat

I am using SimpleDateFormat like this: SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HH:mm:ss.SSS"); Date result = sdf.parse("20221114-12:34:56.789"); Works fine for the ...
Csaba Faragó's user avatar
5 votes
3 answers
3k views

How to get the date and time in format 2022-10-03T19:45:47.844Z in Java

I need the current system date and time in 2022-10-03T19:45:47.844Z format in a java class. I tried using the zoneddatetime and simple date format but couldn't get the write syntax or code from online....
Pranoy Kakubal's user avatar
0 votes
0 answers
111 views

Null Pointer Exception on SimpleTimestampFormat.parse(SimpleTimestampFormat.java:347)

I am trying to load a file into an application but while loading it throws an error 2022/11/03 19:35:49 - ExtractRowDataTimeStamp.0 - ERROR (version 8.2.0.0-342, build 8.2.0.0-342 from 2018-11-14 10....
rupal khatua's user avatar
2 votes
1 answer
98 views

Why Jdk DateFormat use StringBuffer instead of StringBuilder?

I checked Jdk19 source code and I noticed that DateFormat always uses StringBuffer when formatting a Date into String. Shouldn't that be StringBuilder because it's faster?
user avatar

1
2 3 4 5
53