Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 12th, 2005, 04:38 PM
RVA RVA is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2005
Posts: 1 RVA User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 55 sec
Reputation Power: 0
JSP - Getting the Client System Date and Time to Display on Page

Hi, I need an immediate help over this. Thanks in advance.

Problem:

I have my application running on server that is there in some other time zone. I need to display the date and time zone of the user system on the home page of the application. Curently it is displaying the date and time of the zone where the server is located. I have used alomost each and every JavaAPI related to this in my JSP but again and again it is showing me the server's date and time.

Pls Help!!!!

RVA

Reply With Quote
  #2  
Old May 14th, 2005, 02:02 PM
gertcuppens's Avatar
gertcuppens gertcuppens is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 118 gertcuppens User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 28 m 17 sec
Reputation Power: 11
Perhaps I give you a solution that you've tried already
and that did not work out. Anyway, you should take a look
at the locale. The Locale is a class that determines specific
properties of the computer of the user. In "Java, how to program
sixth edition" of Deitel, I found this piece of code.

Code:
 <% 
  // get client locale
  java.util.Locale locale = request.getLocale();
 
  // get Dateformat for client's locale
  java.text.DateFormat dateFormat =
	 java.text.DateFormat.getDateTimeInstance(
		 java.text.DateFormat.LONG,
		 java.text.DateFormat.LONG, locale);
 
%>
 
<%=dateFormat.format( new java.util.Date() ) %>

Try this out and let us know if this was the solution.

Reply With Quote
  #3  
Old August 8th, 2007, 07:36 AM
AppleMan AppleMan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 1 AppleMan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 sec
Reputation Power: 0
Well, we'd faced a similar situation. My team mate added a attribute, say localTime in our form and wrote a piece of Javascript code to find the time.We called this code on load of our page and which set teh local date time value to our form attribute.It was then used in our JSP to display the Local time

Find the piece of code below :
JS

function showDate(){
var datetime= new Date();

var dateonly=datetime.getDate();
var dateyear=datetime.getFullYear();
var datemonth=datetime.getMonth();
var hours=(datetime.getHours());
var minutes=(datetime.getMinutes());
var seconds=(datetime.getSeconds());
var daytime="AM";
if (hours>12) {
daytime="PM";
hours=hours-12;
}
if(hours==12)
daytime="PM"
var totaltime=dateonly+"/"+datemonth+"/"+dateyear+" "+hours+":"+minutes+":"+seconds+" "+daytime;
document.forms[1].timedate.value=totaltime;

}
Now the timedate is added to oour form

and on page load we are calling this method
javascript:showDate();

We are displaying this on the JSP as below

<td width="100%" align="RIGHT"><html:text property="timedate" name="OurFormName"
style="background-color:transparent;border:0px solid white;"/></td>

Hope it helps

AppleMan

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > JSP - Getting the Client System Date and Time to Display on Page


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap