Note that there are some explanatory texts on larger screens.

plurals
  1. POproblem with simple parse routine
    primarykey
    data
    text
    <p>this problem is killing me, here is my code</p> <pre><code>import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Converter { // 8/12/2010 12:20:34 PM static String DATE_FORMAT = "MM/dd/yyyy h:MM:ss aa"; // from object to xml public static String serializeNCCDate(Date d) { try { System.out.println("serializeNCCDate"); SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); System.out.println("in from object: " + d.toLocaleString()); String s = sdf.format(d); System.out.println("out to object: " + s); return s; } catch (Exception ex) { return null; } } // from xml to object public static Date deSerializeNCCDate(String s) { try { System.out.println("deSerializeNCCDate"); SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); System.out.println("in from xml: " + s); Date d = sdf.parse(s); System.out.println("out to object: " + d.toLocaleString()); return d; } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } } </code></pre> <p>then running my tests im putting an xml document into my xml engine (jibx) to convert to an object and then putting the object back into jibx to convert it back to a string. when i try to serialize the date "8/12/2010 12:20:34 PM" from my xml, this is the result i get</p> <pre><code>deSerializeNCCDate in from xml: 8/12/2010 12:20:34 PM out to object: Aug 12, 2011 12:00:34 PM serializeNCCDate in from object: Aug 12, 2011 12:00:34 PM out to object: 08/12/2011 12:08:34 PM </code></pre> <p>why are my years and minutes not what they should be? seems like every time the parse function is called the output that it should be changes. this is pretty simple stuff, why is it not working? i could understand the hours being wrong with time zone differences, but the years and minutes?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload