Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9136423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:57:02+00:00 2026-06-17T08:57:02+00:00

The goal I’ve got a really strange problem. My goal is to compare a

  • 0

The goal

I’ve got a really strange problem. My goal is to compare a dynamic date in database using dbunit (the database is an Oracle one). This dynamic date is the today date (comparing static date works…)

The experimentation

To compare date, I use this very simple code :

@Test
public void simpleDateTest() throws DatabaseUnitException, SQLException {
    // create a date corresponding to today
    Date today = new Date();

    // load a dataset
    IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(getClass()
            .getResource("/dataset.xml"));

    // replace [TODAY] by the today date
    ReplacementDataSet rDataSet = new ReplacementDataSet(expectedDataSet);
    rDataSet.addReplacementObject("[TODAY]", today);

    // insert the dataset
    DatabaseConnection connection = getConnection();
    DatabaseOperation.CLEAN_INSERT.execute(connection, rDataSet);

    // do a simple query to get some fields, em is the entity manager which uses the same connection as above
    Query q = em
            .createNativeQuery("SELECT ID, MY_DATE FROM MY_TABLE");
    List<Object[]> result = q.getResultList();

    // compare the date with today date
    assertEquals(today.getTime(), ((Date) result.get(0)[1]).getTime());
}

With the following dataset :

<?xml version='1.0' encoding='UTF-8'?>
<dataset>
    <MY_TABLE ID="1" MY_DATE="[TODAY]" />
</dataset>

The problem

I don’t know why, but the assert failed ! When comparing the two dates, there is a very few milliseconds difference. The error is something like that :

java.lang.AssertionError: expected:<1358262234801> but was:<1358262234000>

I don’t understand how is it possible to have different dates because they are quite normally the same !
Any clue to understand the problem and how to solve it ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:57:03+00:00Added an answer on June 17, 2026 at 8:57 am

    The Oracle Date type doesn’t have a resolution of milliseconds, it only has a resolution of seconds.
    When saving a time to the database the milliseconds are simply stripped off. When you look at the actual value you see that the last three digits are all zero.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Goal: Gain datatype date with year and month Problem: Need to help to convert
Goal: Post Image using RestTemplate Currently using a variation of this MultiValueMap<String, Object> parts
Goal Replace one div with another after 5 seconds delay using jQuery. Description I
Goal : check java's version on a machine (I can get this from java
Goal: To render a google map using geolocation. I am trying to implement the
Goal: To use entity framework with N-tier in my WPF application. Problem: I can't
Goal: User only selects one , only one option at a given time for
Goal: Allow user to select one or more images from his photo library. Get
Goal: Convert any local date to the according ISO date My Approach: http://codepad.viper-7.com/XEmnst strftime(%Y-%m-%d,strtotime($date));
Goal: I am trying to acquire the size of the iris (width/radius) using video

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.