Jump to content

Date Format Processing

- - - - -

  • Please log in to reply
2 replies to this topic

#1
sam_coder

sam_coder

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 372 posts
Hey Guys,

I have a date format coming in, and I'm uncertain the best way to ingest it with Java.

the date format looks like this.

2019-09-19T23:59:59-03:00

I get that it's Year, Month, Day, Hours, Minutes, Seconds
And I think the -03:00 is a GMT offset.

normally that is denoted like this:
-0300, is it not?

Should this be handled with a SimpleDateFormat, something like this?

new SimpleDateFormat("yyyy-MM-ddTHH:mm:ssZ");

or would something else be more appropriate?

Many Thanks!

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
You gonna need single quotes around the 'T' to make the format work.
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
But then you're still left with the issue of having the unwanted semicolon at the timezone.

I guess it's easiest to just get rid of it manually.
dateString = dateString.substring(0, dateString.lastIndexOf(":")) + dateString.substring(dateString.lastIndexOf(":")+1);


#3
sam_coder

sam_coder

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 372 posts
Many thanks! Glad to know I wasn't too far off the mark! =)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users