dcsimg
Log4J Using time for long diferent from Locale
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, August 14, 2007 03:18 AM

I have and old application that i must to actualice to support some new funcionalitys.

The problem i have is with the time that log shows, cos i dont have a server side part, each user uses his locale time to input log.

Some users are in diferent countries and some others change time of PC with nosense.

I can get a timeStamp with JDBC from database but i dont know how to do that log4j use this timestamp for log time.

Thks in advance for any help you can provide me and also sorry by my speeling.

Cheers.

Re: Log4J Using time for long diferent from Locale

Posted By:   Anonymous  
Posted On:   Tuesday, August 14, 2007 08:45 AM

//Get date from DB and find the delta with system date. You can use that delta eachtime for logging the date



1. SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

2. Date dateFromDB = df.parse(DB Date);


3. Calendar cal = Calendar.getInstance();


4. long diffInMillis = dateFromDB.getTime() - cal.getTime().getTime();


//Add the delta in milliseconds column with system date, so that we can maintain DB date. No need to access DB everytime

5. cal.add(Calendar.MILLISECOND, (int)diffInMillis);



Step 1-4 are onetime task, and you can do as like in step 5 eachtime you log something.



Mail me @ muhu79@gmail.com for more details
About | Sitemap | Contact