Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

difference between Calender on windows and linux

Status
Not open for further replies.

sjakiePP

Programmer
Apr 6, 2004
104
NL
Hi,

On a Win 2000 I use following to determine todays date:

Code:
Calendar rightNow = Calendar.getInstance();
int year = rightNow.get(rightNow.YEAR);
int month = rightNow.get(rightNow.MONTH);
int day = rightNow.get(rightNow.DAY_OF_MONTH);
int hour = rightNow.get(rightNow.HOUR_OF_DAY);
int minute = rightNow.get(rightNow.MINUTE);
String lDate = "" + year + "-" + month + "-" + day + " - " + hour + ":" + minute;

When I use this on a linux machine The date is not correct. It says it is 2004-8-7. How can I fix this?

thanks in advance
Sjakie

---------------------------------------------
Yes, the world is full of strange people.
 
I've tried this on Win32 (XP) and also linux (red hat 9) and there is no difference (and there should be none). It must be something you are doing ...

--------------------------------------------------
Free Database Connection Pooling Software
 
I wish I knew what. The system date of the machines used, is correct. Is it so that months in calender start at 0? Like january = 0, february = 1, and so on.

I solved it with following:

Code:
SimpleDateFormat lSdf = new SimpleDateFormat ("yyyy-MM-dd - hh:mm");
Date currentDate = new Date();
String dateString = lSdf.format(currentDate);

This works the same.

Thanks.

---------------------------------------------
Yes, the world is full of strange people.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top