aspose file tools*
The moose likes JForum and the fly likes Post time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JForum
Bookmark "Post time" Watch "Post time" New topic
Author

Post time

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hi ,

The time of posting shows the server time.
Even though server is in different geographical location,is it possible to set it to indian time?

otherwise can I set the client time as the time of posting?
So which part of the code i should look into?

Thanks,
Razia
[originally posted on jforum.net by razia]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
You can take a look at net/jforum/view/forum/PostAction.java, method insertSave(). There you'll find a call to setPostTime() somewhere.

Rafael
[originally posted on jforum.net by Rafael Steil]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Thanks for your reply.

in net/jforum/view/forum/PostAction.java, method insertSave(),

inside if (newTopic) { ///code

I replaced t.setTime(new Date()) with

TimeZone timeZone = TimeZone.getTimeZone("Asia/Calcutta");

Date date = Calendar.getInstance(timeZone, Locale.US).getTime();
t.setTime(date);

and also in /jforum/view/forum/PostCommon.java in method Post fillPostFromRequest()
I replaced p.setTime(new Date()); with

TimeZone timeZone = TimeZone.getTimeZone("Asia/Calcutta");

Date date = Calendar.getInstance(timeZone, Locale.US).getTime();
p.setTime(date);

.....
But it didn't work.
When I wrote the code as standalone java application i got my system time.


..........
in generic_queries.sql

It is given
PostModel.addNewPost = INSERT INTO jforum_posts (topic_id, forum_id, user_id, post_time, poster_ip, enable_bbcode, enable_html, enable_smilies, enable_sig, post_edit_time, need_moderate) \
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?)


So, Does this mean post time is fetched in the query level by using now() function?

In that case how to manipulate this?

Thanks
Razia

[originally posted on jforum.net by razia]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
The times in most of the jForum schema's are DateTime. For most SQL servers this is like Java's Date object. It's just a big integer number that is the millisecs or secs since some base GMT date.

Even if the server time is set to US Eastern Time and you are in India, Now() is still the same integer number.

So, IMHO, the problem is not in the STORING of the date, but in the DISPLAY of the date. DateFormat objects that are created without either a locale or having a TimeZone set will use the JVM's default settings.

So this means that all the SimpleDateFormat instances will need to be tracked down and modified. Or, if you control the JVM on the server, you can probably modify the default locale via a start up parameter so you get the correct time.

Best way to deal with it is to have a default timezone and a user preference option. (Hmm, maybe the default should be settable at the category, forum level too?)
[originally posted on jforum.net by monroe]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Post time