Main topic: How to determine this date is a day, please help. Servers: R9lu (fish in late swimming) Credit value: 100 Forum: Java JSP / servlet / javabean problem points: 20 replies: 13 Posted: 2004-8-24 16:30:06 There are two small problems
1. What is the value of the date type (04-8-24 0: 0: 0: 0) from a result set, how to save him to a variable
2. How do you get the date of the day if you save your dates into a character.
The ultimate goal hopes to get this date is the day of the week. Even the novice, please help solve it.
Reply to: Nanman (Nanban-500,000 author used by the strongest five author) () Reputation: 120 2004-8-24 16:35:37 Score: 5 TimeStamp Date = rs.getTimeStamp (n);
Calendar Cal = Calendar.getInstance ();
Cal.SetTime (date);
INT week = caver.get (calendar.day_of_week); // Week
TOP
Reply to: r9lu (fish in the evening) () Reputation: 100 2004-8-24 17:00:57 Score: 0 When compiled:
Cannot Resolve Symbol
Class TimeStamp
Method getTimeStamp
TOP
Reply to: Power17 () () Reputation: 105 2004-8-24 17:18:11 Score: 5
The worst method in the world:
<% @ Page ContentType = "Text / HTML; Charset = GB2312" Language = "Java" Import = "java.sql. *" ErrorPage = ""%>
<% @ Page Import = "java.util. *"%>
hEAD>
<%
Java.util.date Date = new java.util.date (104, 8, 24, 0, 0);
Out.println (Date.getDay ());
%>
body>
html>
TOP
Reply to: AOPLO (Brother) () Reputation: 97 2004-8-24 17:19:55 Score: 2 See your RS.GetTimeStamp (n); the field of N) is not a date type, don't The corresponding is wrong.
Nanban should have no problem!
TOP
Reply to: wwwer1 (Wuling Herger) () Reputation: 100 2004-8-24 17:30:12 Score: 0 There is also a simple way to calculate directly in SQL, but not very good
For example, in SQL Server: SELECT datepart (weekday, '2004-8-23')
The following date can be replaced with the field in your database
TOP
Reply to: Power17 () () Reputation: 105 2004-8-24 17:33:53 Score: 3 <% @ Page ContentType = "Text / HTML; Charset = GB2312" Language = "Java" Import = "java.sql "" ErrorPage = ""%>
<% @ Page Import = "java.util. *"%>
hEAD>
<%
Calendar Date = Calendar.getInstance ();
Date.set (104, 8, 24, 0, 0);
Out.println (Date.Get (Calendar.day_of_week);
%>
body>
html>
TOP
Reply to: DDO831 (This user can't be blocked) () Reputation: 100 2004-8-24 17:50:16 Score: 0, rs.gettimestamp (n); What is the RS in?
TOP
Reply to: r9lu (fish in the evening) () Reputation: 100 2004-8-24 17:50:59 Score: 0 I can realize this method
Int z;
String weekstr = ""
Date tmpdate = new date ();
z = tmpdate.getday ();
Switch (z)
{
Case 0:
Weekstr = "Sunday";
Break;
Case 1:
Weekstr = "Monday";
Break;
Case 2:
Weekstr = "Tuesday";
Break;
Case 3:
Weekstr = "Wednesday";
Break;
Case 4:
Weekstr = "Thursday";
Break;
Case 5:
Weekstr = "Friday";
Break;
Case 6:
Weekstr = "Saturday";
Break;
}
But the getday () method is only Date type data, and my date value is obtained from a result set, how to save this dates value into a variable and still DATE.
I am using String RundateStr = ParentBean.getstring ("Rundate");
Can only save it into a string type
Ask you.
TOP
Reply to: r9lu (fish for a day to night) () Reputation: 100 2004-8-25 10:30:03 Score: 0 Please help us to see Top
Reply to: chDW (m) () Reputation: 150 2004-8-25 10:32:30 Score: 2 getTimeStamp (int columnIndex) is the standard method of ResultSet, how can it be
You are wrong, or your RS is not a resultset type.
TOP
Reply to: zhaoqiubo (Zhao Xiaojian) () Reputation: 100 2004-8-25 11:02:51 Score: 1 Translation:
Cannot Resolve Symbol
Class TimeStamp
Method getTimeStamp
No import timestamp this thing ...
TOP
Reply to: swiminthesea (blogd coated) () reputation: 100 2004-8-25 11:17:54 Score: 1 Translation error:
Cannot Resolve Symbol
Class TimeStamp
Method getTimeStamp
Yes, IMPORT JAVA.SQL.TIMESTAMP;
TOP
Reply to: hiking () () Reputation: 100 2004-8-25 12:04:20 Score: 1 There is another question to pay attention:
Date in the SQL package is different from the Date in the Util package!