Distinctive and analytic dates in Java

I know this topic is not new, although I need to dig it up again. I have searched the website more than once (including some threads here on stackoverflow), but have not yet found a satisfactory answer.

(Among others, I checked Parsing ambiguous dates in Java and http://www.coderanch.com/t/375367/java/java/Handling-Multiple-Date-Formats-Elegantly

I am currently writing a Dateparser in Java that takes a date and generates a String format that SimpleDateFormat can use to parse the date.

Dates are parsed using a regular expression (yes, that ugly one xD) from Logfiles (IBM Websphere, Tomcat, Microsoft Exchange, ....). Since we have clients (at least 2) of different locales, there is no way to just throw the String against the parse SimpleDateFormat method and expect it to work correctly.

In addition, there is a problem with the position of the day and month (ie the “dd / MM / yyyy” or “MM / dd / yyyy” formats) which cannot be resolved if I do not have at least two sets data where the daily number has changed.

Thus, my current approach would be to store date formats for specific software installed on specific client systems in the database (mysql / xml / ...), and force the user to at least specify a username and softwarename so that there was enough context to break down the number of possible options, a format can be specified.

This "subset" will then be used to analyze the log files of the specified software. (The subset is stored in the HashMap in the HashMap in the form HashMap> map; the Integer key is the length of the format string, and the string key of the second Hashmap indicates a date containing only separator characters. (Ie ".. ::." For a date with format "dd.MM.yyyy 11: 11: 11.111")

, .. a > 12 , 13- . Date-Strings 12- .

, , ?

3 .

=)

Edit:

, , . . , : Logreader Java. , . , . , , , - . . , , . , , , .

, . , . java.util.Date, Date Timestamp . , , - , , .

. , 23:59. ​​ " ", .

=) ( , ;))

+3
3

, "" , . (, .) , , .

, (, NULL), , . , , .

, , :

dd/mm/yyyy
mm/dd/yyyy
yyyy/mm/dd
yyyy/dd/mm

, ( ). , :

25/01/2011 -> UNAMBIGUOUS_DD_MM_YYYY
12/01/2011 -> AMBIGUOUS_XX_XX_YYYY
2011/03/03 -> AMBIGUOUS_YYYY_XX_XX
03/30/2011 -> UNAMBIGUOUS_MM_DD_YYYY
+1

, dateformat .

.

....., '03/11/2011 ',' MM/DD/YYYY ',...

0

I think that the strategy you are going to (for example, analyzing a larger dataset) is the best you can get. From one line of the logfile, you will never know whether 3/5/11 is the 3rd of them in 2011 or the 5th march in 2011. (I think there may also be locales that could interpret this as May 11th, 2003 ...) I had problems with this a while ago, and I could only try to enter some context, either by looking by numbers> 12, or those that change faster (there should be a "day"). But you already stated that you yourself ...

0
source

All Articles