0

import java.util.*;
import java.text.*;
class DemoDate
{
public static void main(String[] args)
{
Date date=new Date();
SimpleDateFormat sdf;
// sdf=new SimpleDateFormat("hh:mm:ss");
//System.out.println(sdf.format(date));
// sdf=new SimpleDateFormat("dd MMM yyyy hh:mm:ss zzz");
//System.out.println(sdf.format(date));
sdf=new SimpleDateFormat("E MMM dd yyyy hh:mm:ss");
System.out.println(sdf.format(date));
}
}

i am getting current date and time but i want to catch that time (as a login time 4 a person)in my jsp whenever i refresh i am getting current system time .Suppose i logged in at 2:00 that time should be there ...................plz help me

2
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by masijade
0

By assigning the date object to a session variable at login, then simply displaying that date at every other page load rather than creating a new date (as you are doing now). A new date object will always hold the current time at the time of construction (at least when created using the default constructor).

0

Please don't send me personal messages about this. Keep the conversation here, so that anyone else with this type of question can also benefit.

Post your code here, and then we can continue.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.