Questions tagged [date-parsing]

Date-parsing refers to programming logic which reads one or more parameters, attempts to match it to a supported or specified date format, then returns the resulting Date if successful.

References

494 questions
-2
votes
2 answers

Parsing LocalDate in Java: What's the pattern for "March 26 2020"

I can't seem to come up with a pattern for "March 26 2020" (no comma). Can someone help? I've tried DateTimeFormatter.ofPattern("MMMM dd yyyy") and DateTimeFormatter.ofPattern("MMM dd yyyy"). Minimal reproducible example: String strDate = "March…
CNDyson
  • 1,687
  • 7
  • 28
  • 63
-2
votes
1 answer

Need format the give string "18-MAY-92" using stringTokenizer and get int value of month

I am trying to format the date which is entered as a string using string tokenizer. Date format will be enter as String str="18-AUG-92". I am splitting it into int ndate = Integer.parseInt(str.nextToken()); int nmonth =…
-2
votes
1 answer

Convert second to years, days, hours, minutes and seconds

help me with this one problem. I am confused how to convert second to years, days, hours, minutes and second in JavaScript. This below as an example convertSeconds(10000)) // 2 hours, 46 minutes and 40 seconds convertSeconds(62)) // 1 minutes and 2…
John Doe
  • 9
  • 5
-2
votes
2 answers

Convert String to Date in format mm/dd/yyyy HH:mm-HH-mm Zone

I have a date in the format 07/18/2018 01:00-04:00 CDT in a String variable. where 01:00-04:00 is a time range. I need convert this into a date format in two separate variables keeping timezone in mind. Var1 should have 07/18/2018 01:00 CDT Var2…
chingupt
  • 403
  • 2
  • 7
  • 19
-2
votes
4 answers

How to parse this date format (dd-m-y) in java

I am facing some problem to parse the date format dd-m-y with SimpleDateFormat class in Java. So is there any date formatter for this date format type (12-oct-14)?
kunal
  • 163
  • 1
  • 14
-2
votes
1 answer

SimpleDateFormat.parse("MM/yyyy")

I am trying to implement a method which parses String to Date, and I would like to use SimpleDateFormat because that seems to do the work: java.util.Date parseMonth(String str) throws ParseException { SimpleDateFormat format=new…
Frank Endriss
  • 120
  • 3
  • 10
-2
votes
4 answers

Adding months to dates

I want to add the number of months based on the duration selected by the user. I have written the following code, it is taking the current date and adding months based on duration selected by user but I want it to take the start date passed from…
Pragati Kerur
  • 145
  • 1
  • 13
-2
votes
1 answer

Parsing a string to date gives a completely different date in Android

The string is of the format dd/mm/yyyy I am parsing using the following code:- Dateformat dateformatter = new SimpleDateFormat("EEE, MMM d, ''yy"); dateformatter.setLenient(false ); String temp = "7/07/2017" Date date = null; try { date = new…
venutamizh
  • 53
  • 8
-2
votes
1 answer

localdate parsing can't parse hours and minutes

I need to get the date from a String, the format is the following: uuuu-MM-dd HH:mm The input has that format and I want the same format for my dates (year-month-day hour:minutes). When I did this: LocalDate aux =…
Aikas
  • 67
  • 2
  • 7
-2
votes
3 answers

Convert string dates in java

I need to compare two string dates in java: String date1 = "2017-05-02"; String date2 = "5/2/2017"; //formatter for the first date SimpleDateFormat formatter = new SimpleDateFormat("yyyy-mm-dd"); Date formattedDate1 =…
Alex Smoke
  • 619
  • 1
  • 8
  • 18
-2
votes
2 answers

How to convert a date string from "dd-MMM-yy" to "M/dd/yyyy hh:mm:ss tt"?

I need to compare two date format strings: dateString in "dd-MMM-yy" format with referenceDateString in "M/dd/yyyy hh:mm:ss tt" format respectively. For that, I need to convert the dateString = "dd-MMM-yy" to "M/dd/yyyy hh:mm:ss tt". However, Got…
JCurious
  • 11
  • 1
  • 1
  • 4
-2
votes
2 answers

Java SimpleDateFormat throws no ParseException

i want parse some Dates.. i do this with the following code: ULocale tmpLocale=Locale.US try { return parse(date, "yyyy-MM-dd HH:mm:ss.SSS",tmpLocale); } catch (ParseException e1) { try { return parse(date,…
user2115378
  • 931
  • 3
  • 14
  • 22
-3
votes
1 answer

Parse a string "Unknown" to date in java

I am trying to parse a string in java that comes like this: String test="Unknown" But users data wants this string as date. Can it be a way to parse or avoid this case? For example that date to be taken like empty, instead of unknown?
Ester
  • 19
  • 7
-3
votes
1 answer

java.lang.NumberFormatException: For input string: “2019-11-27”

In my app I am getting date from an API server as String value and I want to parse it to int but I get this error: Caused by: java.lang.NumberFormatException: For input string: "2019-11-27" at java.lang.Integer.parseInt(Integer.java: 521) at…
Mohammed Qadah
  • 75
  • 1
  • 10
-3
votes
1 answer

Conversion from String to Date Not happening in JAVA

I have english date coming in string format such as 2011-12-12. I need to convert it into Date format so I tried : String assignDates="2011-12-12"; DateFormat df = new SimpleDateFormat("YYYY-MM-dd"); Date dates = df.parse(assignDates); …
ashwin karki
  • 643
  • 5
  • 19
  • 35
1 2 3
32
33