4 Replies Latest reply: Apr 9, 2010 4:25 PM by jschellSomeoneStoleMyAlias RSS

    java.text.SimpleDateFormat  with zones

    807580
      Hi,

      I have a log file which has a date format as below:

      20091224060656.000000+060

      Wondering if java.text.SimpleDateFormat would be able to parse it properly.I was seeing this API and it didnot have any exact syntax for parsing this kind of date format.

      Please let me know.

      Regards
      Sayan
        • 1. Re: java.text.SimpleDateFormat  with zones
          jschellSomeoneStoleMyAlias
          +060
          Does that represent hours or minutes?
          • 2. Re: java.text.SimpleDateFormat  with zones
            807580
            Hi,

            Thank you for the response.The problem is this is one our client's log file which we are trying to parse using the java.text.SimpleDateFormat from our own java application.

            Hence not sure about +060. I guess the part after the . represent the zone , please correct me.But +060 not sure what this means and I dont think java.text.SimpleDateFormat has a way to parse this.

            Please let me know your comments.
            • 3. Re: java.text.SimpleDateFormat  with zones
              masijade
              sayanb wrote:
              Hi,

              Thank you for the response.The problem is this is one our client's log file which we are trying to parse using the java.text.SimpleDateFormat from our own java application.

              Hence not sure about +060. I guess the part after the . represent the zone , please correct me.But +060 not sure what this means and I dont think java.text.SimpleDateFormat has a way to parse this.

              Please let me know your comments.
              Uhm, you need to "tell" SimpleDateFormat what the format is, if you don't know how to interpret the format, how are you going to be able to configure SimpleDateFormat. Contact your "client" and make sure you understand the format, then look at the API docs for SimpleDateFormat and hammer out a pattern string for that format. (But I would assume that the "part after the dot" is second fragments (smaller than milliseconds but larger than nanoseconds, about half-way between, what the name for that is, I'm not sure), and that the part with the "plus" is the timezone, probably +060 is the same as +0600.) IOW, you will probably have to "preprocess" the string removing the last three digits before the "plus" and adding a 0 to the end, but that is only a guess.
              • 4. Re: java.text.SimpleDateFormat  with zones
                jschellSomeoneStoleMyAlias
                sayanb wrote:
                Hi,

                Thank you for the response.The problem is this is one our client's log file which we are trying to parse using the java.text.SimpleDateFormat from our own java application.

                Hence not sure about +060. I guess the part after the . represent the zone , please correct me.But +060 not sure what this means and I dont think java.text.SimpleDateFormat has a way to parse this.
                My guess would be the part after the period represents fractional seconds. And the 060 represents minutes.

                But it doesn't matter because computers don't guess. If you don't know what it does then the computer is never going to figure it out. So the first step is not writing code but finding out what the format means.