I have a timestamp which is in the form of String(retrieved from LDAP) for example :20041118120738Z I have to find the no.of.days different between this timestamp and currenttimestamp. if I go for, System.currenttimeMillis() to get CurrentTime, is this locale depenedent?? Can any one assist me?
You can convert your time stamp to a java.util.Date object using the SimpleDateFormat class. Once you have the Date object, you can convert that to the milliseconds representation by calling the getTime() method.
Subtract that from the current time, and you'll have the number of milliseconds between the two time stamps. This is easily converted to days.
As for the locale question - System.currentTimeMillis() will return whatever time is reported by the system clock on the machine where your program is running. So, yes, it is locale dependent - if you run the same program at the same time on two different machines in different time zones, you will get different results. [ November 29, 2004: Message edited by: Fletcher Estes ]
subject: How do I calculate the no.of.days. between two timestamps?