Ok,
Thank you..
Then..How can I print the time and date in the HTML page using JSP?I want to
show the time as '15 Nov,2000 09:41 P.M'.
Can you specify that also?
Thanx again...
 Cheers,
 Jam.
----- Original Message -----
From: Vishnu Akkaraju <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, November 15, 2000 9:19 PM
Subject: Re: current time to java.sql.Date


> hi,
>
> construct current time & date as
>
> java.sql.Timestamp ts = new
> java.sql.Timestamp(System.getCurrentTimeMillis());
>
> and then use
>
> pstmt.setTimestamp(..,ts);
>
> ....
>
> hope this helps you
> vishnu.
>
> -----Original Message-----
> From: Louis [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, November 15, 2000 5:33 PM
> To: [EMAIL PROTECTED]
> Subject: Re: current time to java.sql.Date
>
>
> > Hi,
> >  Here is my problem..I want to insert the current date to a table of a =
> > database.How can I get the current date in java.sql.Date?I used the =
> > following code,but I think it is not a good idea?Can anyone help me to =
> > find a solution?
> > The code is....,
> > public java.sql.Date getDate()
> > {
> >     GregorianCalendar gc=new GregorianCalendar();
> >      int y=gc.get(Calendar.YEAR);
> >     int m=gc.get(Calendar.MONTH)+1;
> >     int day=gc.get(Calendar.DATE);
> >     String d=""+y+"-"+m+"-"+day;
> >     java.sql.Date date1=java.sql.Date.valueOf(d);           /*string =
> > to date*/
> >   return date1;
> > }
>
> I also use this method, hope someone have a good solution.
>
>
> > And I also want to convert java.sql.Date to a String of format '15 =
> > Nov,2000'
> > I used the following code,please send me a better way
> >
> > public String getString(java.sql.Date d2)
> >   {
> >     String mo[]=3D =
> >
{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}=
> > ;
> >     GregorianCalendar gc=new GregorianCalendar();
> >     gc.setTime(d2);
> >     int m=gc.get(Calendar.MONTH);
> >     int year=gc.get(Calendar.YEAR);
> >     int dy=gc.get(Calendar.DATE);
> >     String str=""+dy+" "+mo[m]+","+year;
> >     return str;
> >   }
>
> You can use SimpleDateFormat to do this.
>
> java.text.SimpleDateFormat sf = new
> java.text.SimpleDateFormat("dd-MM-yyyy" ); file://you can use other
format, check
> javadoc
> _date = sf.format(d2)    ;
>
>
> > I'm using access db and there is only field for date&time ,then how can
=
> > I insert  current date & time to the table?
> PrepareStatement have a method call setDate(java.sql.Date)  pass your date
> to here, thats it.
>
> > Andow can I show the time in HTML page with client's time zone using =
> > JSP?
>
> Other please.
>
>
> > Thanx,
> > Cheers,
> > Jam.
> >
> >
>
===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> >  http://java.sun.com/products/jsp/faq.html
> >  http://www.esperanto.org.nz/jsp/jspfaq.html
> >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> >  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to