• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java date recurrently showing two days ago after querying

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys, Here i'm again Requesting for your always tremendously appreciated help,

Here's the thing:

I have developed a small desktop application wich gets deployed through JNLP in my organization.

When a User needs to access data that contains dates ( stored as date in MSSQL database) keeps getting a two days before after as response,

but if i query the same field of the same database in other machine I get the correct data.

I have even tried to query the date as a string and manipulate it that way

thinking that it would fix the problem, but saddly have gotten the same results.

My question is what could be failing? what should I check for?

and why exactly a two days ago date gets returned

Here the key part of the code that involves the query:


"SELECT * FROM TIB_RECEPCION"


try {
Partida= resultado.getString("OR_Partida").toString();
} catch (Exception e) {
}



where or_partida is the date field

which gets the result under the format yyyy-MM-dd

then i need to format it to present it to the user
under the format dd/mm/YYYY
to be sure that the data want to display is the correct i handle it entirely as String or Chars

with this method

public String convertirFechaStringaToDateMostrar(String fecha) {

int longitud=fecha.length();
String FechaMagica=fecha;
String oS="";
String nS="";
char Octavo=0;
char Noveno=0;

for (int i=0;i<longitud;i++)
{
// System.out.println("caracater en la posicion "+i+"es"+FechaMagica.charAt(i));

if(i==8)
Octavo=FechaMagica.charAt(i);
if(i==9)
Noveno=FechaMagica.charAt(i);
}
oS=""+Octavo;
nS=""+Noveno;
String F=oS+nS+"/"+FechaMagica.charAt(5) +FechaMagica.charAt(6) +"/20"+FechaMagica.charAt(2)+FechaMagica.charAt(3);
return F;
}



Again this all seems to be ok, but in some machines I get the two days behind date

Any help comment or suggestion would be deeply apprecated

This is making real noise here in my job...

Thanks!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had this problem once using the SQL Server DATE type for a column. I switched it to DATETIME and all was well.
 
Carlos Valderrama
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok bear i'm gonna give it a try!

Hope it works

I'll let you know
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I never did figure out what caused it.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does this help?
http://blogs.msdn.com/b/jdbcteam/archive/2012/01/20/hotfix-available-for-date-issue-when-using-jre-1-7.aspx
 
Carlos Valderrama
Greenhorn
Posts: 14
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Darryl!I'm glad to let you know and all the community that your suggestion has fixed the issue

Bear bibeault thanks for your help too now the dates registered look much better
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:I never did figure out what caused it.


That's ominous.

Presumably, SqlServer DATEs have been working for some time (otherwise there'd be a lot of apps working two days in arrears); so middleware methinks.

Winston
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, we actually nailed it down to the JDBC driver, but never pursued it further as the column should have been a DATETIME to begin with. Based on Darryl's link I would hope that this is an issue that has been fixed in subsequent versions of the driver.
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic