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

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).

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.