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
1 answer

Check if a string is a valid date

I want to put in a constructor an argument of type Date, so I thought that the best way to do that is to write a method that transforms a string into a date. Which is the easiest way to check if my string is a valid date? This is my…
John R.
  • 420
  • 4
  • 14
2
votes
4 answers

Java 6 alternatives for LocalDate and DateTimeFormatter

In a Java 8 project, I can parse the date this way: LocalDate.parse( newDateString, DateTimeFormatter.ofPattern(expectedDateFormat) ) .format( DateTimeFormatter.ofPattern(expectedDBDateFormat) ); My problem is that I have a Java 6…
user880386
  • 2,737
  • 7
  • 33
  • 41
2
votes
6 answers

SimpleDateFormat not parsing date correctly

I'm confused why the following input data is not parsed correctly by SimpleDateFormat. I was trying to test various possible allowed date formats on a String to see if it would parse correctly with one of the formats. Note: Other incorrect date…
George Hernando
  • 2,550
  • 7
  • 41
  • 61
2
votes
1 answer

Is there any rules or importance of order when using multiple optional patterns in DateTimeFormatter

The below code works fine DateTimeFormatter formatter = DateTimeFormatter.ofPattern("[yyyy-MM-dd HH:mm:ss][yyyy-MM-dd]"); System.out.println(LocalDate.parse("1991-01-28", formatter)); System.out.println(LocalDate.parse("1991-01-28 00:00:00",…
Arun Xavier
  • 763
  • 8
  • 47
2
votes
2 answers

Retreive data and time from a datetime string

In my project I have a string like this one: "2018-03-07 06:46:02.737951" I would like to get two variables: one in date format that contains the data, and the other for the time. I tried: from datetime import datetime datetime_object =…
Manuel Santi
  • 1,106
  • 17
  • 46
2
votes
4 answers

Parsing Date and time from "yyyy-MM-dd hh:mm:ss.SSS" -------> "hh:mm aa" in android

Need to convert the time to a specified format but getting a wrong result.Please help DateFormat readFormat = new SimpleDateFormat( "yyyy-MM-dd hh:mm:ss.sss"); DateFormat writeFormat = new SimpleDateFormat( "hh:mm aa"); //Expecting like 05:00…
Nj_96
  • 116
  • 1
  • 1
  • 11
2
votes
2 answers

Reformatting a Date from DD-MMM-YYYY to YYYYDDMM or YYYYMMDD

I'm trying to use Java 8 to re-format today's date but I'm getting the following error: java.time.format.DateTimeParseException: Text '09-OCT-2017' could not be parsed: Unable to obtain LocalDate from TemporalAccessor: …
Orby
  • 428
  • 1
  • 9
  • 24
2
votes
3 answers

Parse Date In Spanish error

Hello Please help me out, I have gone through many questions but didn't get a solution. Code String localDate1="Miércoles, 04 Octubre 2017 12:00 PM"; Locale spanishLocale=new Locale("es", "ES"); SimpleDateFormat spanishLocale1=new…
Pratik Vyas
  • 644
  • 7
  • 20
2
votes
1 answer

Format String into Date considering localization in GWT

I have the problem that I cannot format a String, having in form of "270317" (German version), into a Date. For accomplishing this, I use GWT. What I have so far is this: String input = "270317"; LocaleInfo locale = null; if (locale == null) { …
Bernd
  • 593
  • 2
  • 8
  • 31
2
votes
1 answer

Java DateTimeFormatter parse YearMonth with offset

I'm having problems with parsing a special string representing an year and a month with an offset like this: 2014-08+03:00. The desired output is an YearMonth. I have tested creating a custom DateTimeFormatter with all kind of patterns, but it fails…
andersnylund
  • 190
  • 2
  • 10
2
votes
3 answers

Calendar pickup date format issue

I want to pick a date from calendar pick up to automate my application using selenium webdriver. I am using class SimpleDateFormat under which they support different types of date formats. But I am not sure which type of format need to be take for…
2
votes
2 answers

C++ date parsing with single digits

I am trying to parse a date which contains a single digit for each of the month and the day. The following parses correctly: std::istringstream ss("2015/05/01"); std::tm tmb = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ss >> std::get_time(&tmb,…
Mohak Saxena
  • 81
  • 1
  • 4
2
votes
1 answer

How to change format of this type of date "/Date(1496117136317)/" in AngularJS?

Get date from controller like this /Date(1496117136317)/ in Ajax response and its datatype is datetime. How can I convert its format?
SPnL
  • 338
  • 4
  • 15
2
votes
2 answers

Mac OSX Shell script parse ISO 8601 date and add one second?

I am trying to figure out how to parse a file with ISO 8601-formatted time stamps, add one second and then output them to a file. All the examples I have found don't really tell me how to do it with ISO 8601 date/time strings. Example: read a csv…
HexBlit
  • 1,172
  • 1
  • 13
  • 31
2
votes
1 answer

Parsing a String into Date with DateFormat not parsing correctly

I've been searching all over and just can't find a explanation or reason why this is happening but the parse(String) method of DateFormat just isn't parsing my String correctly. I'm trying to parse a String into the date format that is used for HTTP…
Infiniti Fizz
  • 1,726
  • 4
  • 24
  • 40