date-parsing

d3.js parsing date error with csv file

二次信任 提交于 2019-12-03 21:14:56
I have a problem with parsing dates in a csv file. Have been looking for hours online and in books and testing, without finding the solution. Perhaps someone can help. The code works fine for reading a file with parsing just numbers. But when parsing a file with dates I get the following error message indicating the date format is not recognised: Problem parsing d="MNaN,268.5466377440347LNaN,117.78741865509761LNaN ... The file looks like this: date,value 11-11-13,582 12-11-13,860 13-11-13,940 Code: (js) function myFunction() { d3.csv('data/Date.csv', draw); } function draw(data) { "use strict"

convert String “yyyy-MM-dd” to LocalDateTime

[亡魂溺海] 提交于 2019-12-03 10:41:42
Is there any way to convert a date String to LocalDateTime where the format "yyyy-MM-dd" ? If I try this: DateTimeFormatter DATEFORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDateTime ldt = LocalDateTime.parse(string, DATEFORMATTER); I got this exception: java.time.format.DateTimeParseException: Text '2017-03-13' could not be parsed: Unable to obtain LocalDateTime from TemporalAccessor: {},ISO resolved to 2017-03-13 of type java.time.format.Parsed at java.time.format.DateTimeFormatter.createError(DateTimeFormatter.java:1920) at java.time.format.DateTimeFormatter.parse

NSDateFormatter parses two-digit year as 2046 instead of 1946 or 2040 instead of 1940

北城以北 提交于 2019-12-03 00:02:42
问题 I have a scenario where I'm getting a date string as "46-05-24" (yy-mm-dd), and I need to re-format the date as "1946-05-24". The NSDateFormatter interprets the string as "2046-05-24". I'm using this code: let dateFormatter = NSDateFormatter() dateFormatter.dateFormat = "yy-mm-dd" let gmt : NSTimeZone = NSTimeZone(abbreviation: "GMT")! dateFormatter.timeZone = gmt let dateFromString = dateFormatter.dateFromString(date as String) dateFormatter.dateFormat = "yyyy-mm-dd" if dateFromString != nil

Convert string dates in java [duplicate]

末鹿安然 提交于 2019-12-02 23:22:49
问题 This question already has answers here : Comparing date strings in Java [duplicate] (6 answers) Closed 2 years ago . 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 = formatter.parse(date1); //formatter for the second date formatter = new SimpleDateFormat("m/d/yyyy"); Date formattedDate2 = formatter.parse(date2); //Wrong

NSDateFormatter parses two-digit year as 2046 instead of 1946 or 2040 instead of 1940

雨燕双飞 提交于 2019-12-02 13:18:13
I have a scenario where I'm getting a date string as "46-05-24" (yy-mm-dd), and I need to re-format the date as "1946-05-24". The NSDateFormatter interprets the string as "2046-05-24". I'm using this code: let dateFormatter = NSDateFormatter() dateFormatter.dateFormat = "yy-mm-dd" let gmt : NSTimeZone = NSTimeZone(abbreviation: "GMT")! dateFormatter.timeZone = gmt let dateFromString = dateFormatter.dateFromString(date as String) dateFormatter.dateFormat = "yyyy-mm-dd" if dateFromString != nil{ let dateString = dateFormatter.stringFromDate(dateFromString!) print(dateString) } Is there something

Extract date from String java

我们两清 提交于 2019-12-02 07:16:47
I have a String with several dates, for example: [20-Jul-2012 5:11:36,670 UTC PM, 20-Jul-2012 5:11:36,683 UTC PM] How do I read this string and extract each date? I'm using the SimpleDateFormat class to create a regex. SimpleDateFormat format2 = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss,SSS z a"); I've tried : I've just did, to get the first one and it changes the format and the timezone: ParsePosition parsePos = new ParsePosition(1); SimpleDateFormat format2 = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss,SSS z a"); System.out.println(format2.parse(entry.getValue().toString(), parsePos)) ;

Extract date from String java

家住魔仙堡 提交于 2019-12-02 06:37:50
问题 I have a String with several dates, for example: [20-Jul-2012 5:11:36,670 UTC PM, 20-Jul-2012 5:11:36,683 UTC PM] How do I read this string and extract each date? I'm using the SimpleDateFormat class to create a regex. SimpleDateFormat format2 = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss,SSS z a"); I've tried : I've just did, to get the first one and it changes the format and the timezone: ParsePosition parsePos = new ParsePosition(1); SimpleDateFormat format2 = new SimpleDateFormat("dd-MMM

parse this type of date format in java? [duplicate]

一曲冷凌霜 提交于 2019-12-01 09:33:08
问题 This question already has answers here : Converting ISO 8601-compliant String to java.util.Date (28 answers) Closed 3 years ago . what would be the easiest way to parse this date format below in java?: 2010-09-18T10:00:00.000+01:00 i read the DateFormat api in java and could not find a method that takes a string or even this type of date format as a paremeter to parse? When i mean by parse i mean i want to extract the "date (day month and year)", "time" and "timezone" into seperate string

Parsing with Java 8 DateTimeFormatter and Spanish month names

非 Y 不嫁゛ 提交于 2019-12-01 07:37:08
With the 'old', pre-Java 8 SimpleDateFormat I can do: new java.text.SimpleDateFormat("MMM yyyy", new java.util.Locale("es", "ES")).parse("Mayo 2017") to get the Date object of a date with Spanish month names. How can I achieve the same with Java 8 and DateTimeFormatter ? I tried: DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).withLocale(new Locale("es", "ES")).ofPattern("MMM yyyy").parse("Mayo 2017") but only get a java.time.format.DateTimeParseException . The call to ofLocalizedDateTime() can be removed, because in the end you call ofPattern() , creating another formatter with a

Automatic Date/Time parser without specifying format

社会主义新天地 提交于 2019-12-01 05:54:52
I am searching for a java library that can parse a string into a POJO without specifying the format. I have researched POjava . Is there anyother library which does similar thing? DateTime dateTime = DateTimeParser.parse("21/02/13"); //If unclear use the cultural information passed DateTime dateTime = DateTimeParser.parse("01/02/13", new Locale("en-us")); //Should also work with time zones DateTime dateTime = DateTimeParser.parse("2011/12/13T14:15:16+01:00"); I found the following links with the same problem Intelligent date / time parser for Java , but not very useful answers. Neither Joda or