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.
" ", .
=)
( , ;))