Results 1 to 19 of 19
  1. #1
    Join Date
    Sep 2010
    Posts
    22
    Rep Power
    0

    Default Calender date discard/remove Z and time at the end of the calender date

    Hi,
    I observe that in the Java Calender date when mapping from one calender date eleemnt to another calender date element I am getting calender date appending z or time at the end of the date value. I want to know how to truncate/remove the Z and time from calender date:

    EX:

    <NewArrival date="2011-05+01:00">
    <NewArrival date = date="2011-01Z">

    These red coloured needs to be removed from calender date.

    Please explain how to do that to remove them from calender date.

    Please give the reply soon, its urgent.

    Thanks.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

  3. #3
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    I guess that during your exhaustive search of the API docs you completely overlooked those classes containing "DateFormat" as part of the name.

  4. #4
    Join Date
    Sep 2010
    Posts
    22
    Rep Power
    0

    Default

    Not getting what you are saying. give me an example please how to remove that Z and +01:00

  5. #5
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Read the API docs for DateFormat and SimpleDateFormat and you tell me what you think might work.

  6. #6
    Join Date
    Sep 2010
    Posts
    22
    Rep Power
    0

    Default

    both inpuit element from xml and output element is of type Calender. I am using XMLbeans to convert the mapping from input to output. Can't use dateformat anymore. on the calender date I have to apply any method on that input calender date or output calender date. that I am not able to, please help on that..
    Thanks.

  7. #7
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Yes, you can. If you insists on not even attempting it, then see the API docs for Pattern and use one of the replace methods of String.

  8. #8
    Join Date
    Sep 2010
    Posts
    22
    Rep Power
    0

    Default

    Not able to get what i am expecting. Can some one please give an example as how to do that please..

  9. #9
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    I am unable to get what you are expecting, can you give me an example of it.

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default

    That is a part of the xml schema definition for time, albeit an optional part.
    I wouldn't be surprised to find that XMLBeans has decided to use the full (correct) representation of xs:time, which includes the timezone (or Z, for UTC).
    Any decent XML reader will understand the value output since it is defined as such in the schema.

  11. #11
    Join Date
    Sep 2010
    Posts
    22
    Rep Power
    0

    Default

    Quote Originally Posted by masijade View Post
    I am unable to get what you are expecting, can you give me an example of it.
    like this:

    java.util.Calendar calDate = source.getElementVal(); // which will return calender date.

    target.addNewArrivalDate().setDate(calDate); // here setDate is expecting Calender date.


    Thanks.

  12. #12
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Okay? And the timezone info in that value has a negative effect, how?

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default

    Presumably because someone thinks that XML is supposed to be read by humans rather than being a means of transporting information between systems?

  14. #14
    Join Date
    Sep 2010
    Posts
    22
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    Presumably because someone thinks that XML is supposed to be read by humans rather than being a means of transporting information between systems?
    ok.. But the target system expects date value with out Z and time in the date. Can you pls advice on this..

  15. #15
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default

    Then the target system is wrong.
    Or you are not really using XML, but something that (to a human) looks a bit like XML.

    XMLBeans is designed to work with real XML. If your system isn't designed to work with real XML then I would suggest not using XMLBeans, or fixing the receiving end.

    What's the schema for the data the target system is expecting?

  16. #16
    Join Date
    Sep 2010
    Posts
    22
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    Then the target system is wrong.
    Or you are not really using XML, but something that (to a human) looks a bit like XML.

    XMLBeans is designed to work with real XML. If your system isn't designed to work with real XML then I would suggest not using XMLBeans, or fixing the receiving end.

    What's the schema for the data the target system is expecting?
    it is expecting calender date only. setDate(Calendar date)

  17. #17
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,856
    Rep Power
    19

    Default

    OK.
    So we're not on XML at all then?

    In which case the format is irrelevant, since Calendar does not have a format.

  18. #18
    Join Date
    Sep 2010
    Posts
    22
    Rep Power
    0

    Default

    So you mean it's not possible to remove that Z or time at the end of the Calender date then?

  19. #19
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    No, we're saying that you seemingly don't know how to use the tools you're using. Go back to its documentation and reimplement that part correctly.

Similar Threads

  1. calender
    By sameerRKO in forum Eclipse
    Replies: 0
    Last Post: 02-27-2011, 06:48 PM
  2. Calender
    By dewitrydan in forum New To Java
    Replies: 4
    Last Post: 10-20-2010, 07:36 PM
  3. converting string (GMT date) to date in US time.
    By JRuyechan in forum New To Java
    Replies: 1
    Last Post: 10-15-2010, 07:07 AM
  4. Calender
    By tiger100plus in forum New To Java
    Replies: 1
    Last Post: 12-26-2008, 07:20 PM
  5. date and calender not getting the right results
    By valoyivd in forum New To Java
    Replies: 4
    Last Post: 04-14-2008, 11:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •