title: Why time taken from Oracle is not consistent?
body: <p>I am writing a java application that take the UTC time from Oracle then query on a table if a row match with that time. If there is no results, take the UTC again and so on.</p>
  
  <p>But sometime the time is running backwards or take a step 1 or 2 minutes forware and then continue whit the correct time.</p>
  
  <p>This is the log of the UTC times taken:</p>
  
  <pre><code>15/03/2016 16:42:59 [INFO]  Time (UTC): 21:42:25 {1} 
  15/03/2016 16:42:59 [INFO]  Time (UTC): 21:42:25 {2} 
  15/03/2016 16:42:59 [INFO]  Time (UTC): 21:42:25 {3} 
  15/03/2016 16:42:59 [INFO]  Time (UTC): 21:42:25 {4} 
  15/03/2016 16:42:59 [INFO]  Time (UTC): 21:42:25 {5} 
  15/03/2016 16:43:00 [INFO]  Time (UTC): 21:44:12 {6} 
  15/03/2016 16:43:00 [INFO]  Time (UTC): 21:42:26 {7} 
  15/03/2016 16:43:00 [INFO]  Time (UTC): 21:42:26 {8} 
  15/03/2016 16:43:00 [INFO]  Time (UTC): 21:42:26 {9} 
  15/03/2016 16:43:00 [INFO]  Time (UTC): 21:42:26 {10} 
  15/03/2016 16:43:00 [INFO]  Time (UTC): 21:42:26 {11} 
  15/03/2016 16:43:01 [INFO]  Time (UTC): 21:42:27 {12} 
  15/03/2016 16:43:01 [INFO]  Time (UTC): 21:42:27 {13} 
  15/03/2016 16:43:01 [INFO]  Time (UTC): 21:42:27 {14} 
  15/03/2016 16:43:01 [INFO]  Time (UTC): 21:42:27 {15} 
  15/03/2016 16:43:01 [INFO]  Time (UTC): 21:42:27 {16} 
  15/03/2016 16:43:01 [INFO]  Time (UTC): 21:42:27 {17} 
  15/03/2016 16:43:02 [INFO]  Time (UTC): 21:42:28 {18} 
  15/03/2016 16:43:02 [INFO]  Time (UTC): 21:42:28 {19} 
  15/03/2016 16:43:02 [INFO]  Time (UTC): 21:42:28 {20} 
  15/03/2016 16:43:02 [INFO]  Time (UTC): 21:42:28 {21} 
  15/03/2016 16:43:02 [INFO]  Time (UTC): 21:42:28 {22} 
  15/03/2016 16:43:02 [INFO]  Time (UTC): 21:42:28 {23} 
  15/03/2016 16:43:03 [INFO]  Time (UTC): 21:44:15 {24} 
  15/03/2016 16:43:03 [INFO]  Time (UTC): 21:44:15 {25} 
  15/03/2016 16:43:03 [INFO]  Time (UTC): 21:44:15 {26} 
  15/03/2016 16:43:03 [INFO]  Time (UTC): 21:44:15 {27} 
  15/03/2016 16:43:03 [INFO]  Time (UTC): 21:44:16 {28} 
  15/03/2016 16:43:04 [INFO]  Time (UTC): 21:44:16 {29} 
  15/03/2016 16:43:04 [INFO]  Time (UTC): 21:42:30 {30} 
  </code></pre>
  
  <p>This is a portion of my code:</p>
  
  <pre><code>int arraycounter = 0;
  int index = 0;
  
  while (arraycounter = 0)
  {       
      Connection con = null;
      Statement stmt = null;
      ResultSet rs = null;
  
      String utc_time = "";
  
      String querytime = "select to_char(sys_extract_utc(systimestamp),'HH24:MI:SS') from dual";
  
      try {
          Class.forName("oracle.jdbc.driver.OracleDriver");
          con = DriverManager.getConnection("jdbc:oracle:thin:"+ConnectionString);
          stmt = con.createStatement();
          rs = stmt.executeQuery(querytime);
  
          while(rs.next()) {
              utc_time = rs.getString(1);
          }
  
      } catch (ClassNotFoundException e) {
          e.printStackTrace();
      } catch (SQLException e) {
          e.printStackTrace();
      } finally {
          try {
              rs.close();
              stmt.close();
              con.close();
          } catch (SQLException e) {
              e.printStackTrace();
          }
      }
  
      String query = "select * from table where to_char(date, 'hh24:mi:ss') = '"+utc_time+"'";
  
      index++;
      logger.info("Time (UTC): "+ utc_time +" {"+(index)+"}");
  
      try {
          Class.forName("oracle.jdbc.driver.OracleDriver");
          con = DriverManager.getConnection("jdbc:oracle:thin:"+ConnectionString);
          stmt = con.createStatement();
          rs = stmt.executeQuery(querytime);
  
          while( rs.next() ){             
  
          //save the result into an arraylist
          arraycounter++;
  
          }
  
      } catch (ClassNotFoundException e) {
          e.printStackTrace();
      } catch (SQLException e) {
          e.printStackTrace();
      } finally {
          try {
              rs.close();
              stmt.close();
              con.close();
          } catch (SQLException e) {
              e.printStackTrace();
          }
      }   
  }   
  </code></pre>
  
  <p>Why this is happening?
  Is there a better way of taken the UTC time?    </p>