• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Needing help converting a date to useable format (2012-03-08T18:08:00Z)

 
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to invoke a secure web service, and I have to fill in an element>:
<wsu:Created></wsu:Created>

The only date format I can get to work is 2012-03-08T18:08:00Z
And that has to be UTC time. So I need to find out how to get the current UTC time into that format from SYSDATE.

So far, I can get SYSDATE in UTC:

That gives me the following:
3/8/2012 6:13:00.446294 PM

However, if I use that I am told the date in unparseable..
: java.text.ParseException: Unparseable date: "08-MAR-12 06.13.38.129924 PM"

Can anyone help me get past this last step of converting that date to the format I need it in?
 
Sheriff
Posts: 28329
96
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand why you need to use a database for this. Why can't you just use a Java Date object and format it appropriately? Did I miss something in your problem description?
 
Matt Kohanek
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did not mention I am invoking this service from PL SQL. I am not able to change the web service itself at the moment.
I am creating a wrapper API in our PL SQL code that will invoke this service - in it I am creating the soap request (including this security header)

So is the format I am asking for not a standard one (meaning no proc/func that will do the conversion)? And if not, I am sure there is a way to finagle it into the format I need - is this what I should be looking into?
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd probably be inclined to do the conversion in Java, but of course it is doable in Oracle using the to_char() function:

See also Oracle's Datetime Format Models.

Edit: Oracle supports Java stored procedures, if you need to do a lot of processing in the database and are not that much familiar with PL/SQL, you might try them out, settign the thing up will take some learning too.
 
Matt Kohanek
Village Idiot
Posts: 484
jQuery Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Martin Vajsar wrote:I'd probably be inclined to do the conversion in Java, but of course it is doable in Oracle using the to_char() function:

See also Oracle's Datetime Format Models.

Edit: Oracle supports Java stored procedures, if you need to do a lot of processing in the database and are not that much familiar with PL/SQL, you might try them out, settign the thing up will take some learning too.



Martin - that is similar to what I had in mind when I asked if I would need to finagle the output - I had just not yet figured out the exact syntax to do it.
Thanks very much for the code, I will go with that for now.

I am familiar with Java stored procedures in pl sql - I have written a couple actually. I am much more familiar with PL SQL than java actually.

But you mention doing this conversion in the java. That interests me because I think I looked at this incorrectly in some sense. My understanding was that I can create the soap request in the pl sql, and the date for the security header MUST be in the format I give. So you are saying I can alter the java code so that it accepts the date in some other format? - I can make the java accept something like
<wsu:Created>3/8/2012 6:13:00.446294 PM </wsu:Created>
?

I know this is possible for parameter values I send in to the service <arg1>anydate</arg1> - etc
But since <wsu:Created> is part of the security header, I assumed this date format was all or none.

Is this assumption incorrect then?

Thanks
 
Martin Vashko
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Matt Kohanek wrote:But you mention doing this conversion in the java. (...)


That was a misunderstanding on my part. I, like Paul, assumed you're creating the request in Java, and just take the date from the database as an "authorized source".

I've no idea whether the format in the webservice header can be overriden. But even if it was, obtaining the correct format the way you did would still seem better to me.
 
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic