Jump to content
We've recently updated our Privacy Statement, available here ×

java.util.Date and 0000-00-00


topkatz

Recommended Posts

I have a report that retrives a date object that can be 0000-00-00.  I would like to continue to use the date field for this data in the report for formating reasons.  Is there a way to handle this?  Right now my report dies if my data contains 0000-00-00.

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

I can not reproduce teh error right now as my tables are dumped,  however I can show you the xml and tell you what is going on.

Field deff:

<field name="tbDate" class="java.sql.Date">
        <fieldDescription><![CDATA[]]></fieldDescription>
    </field>

 

Field display:

<staticText>
                <reportElement x="159" y="298" width="41" height="14"/>
                <textElement/>
                <text><![CDATA[TBDate:]]></text>
            </staticText>

 

<textField pattern="MM/dd/yyyy">
                <reportElement x="200" y="298" width="63" height="14"/>
                <textElement/>
                <textFieldExpression class="java.util.Date"><![CDATA[$F{tbDate}]]></textFieldExpression>
            </textField>

 

The problem is that this value is not always a real date,  some times its '0000-00-00'.  When it is, the report fails with an error saying that its not a date.  I know I can work around this by setting the field as a string, but then I can not use the date pattern to alter the date format (which I want to do)

 

 

 

 

Link to comment
Share on other sites

  • 3 months later...

On my php file i put this:

 

$conn = java('java.sql.DriverManager')->getConnection("jdbc:mysql://localhost:3306/database?user=$user&password=$password&zeroDateTimeBehavior=convertToNull");

 

 

I use tomcat + phpjavabridge + wamp, i just changed the connection string

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...