By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,626 Members | 2,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,626 IT Pros & Developers. It's quick & easy.

cannot find mymbol method parseDate(java.lang.String)

100+
P: 274
hi,
I am new at writing JSP and Servlets. When I compile my serverlet I get follwoing error
cannot find mymbol method parseDate(java.lang.String)

I have follwoing code:

Code: ( text )
package admin;

import java.lang.Object.*;
import java.util.*;
import java.io.IOException;
import data.*;
import business.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class AddPaymentServlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
// Payment information

String paymentID = request.getParameter("paymentID");
String clientID = request.getParameter("clientID");
String paymentType = request.getParameter("paymentType");
String paymentAmount = request.getParameter("paymentAmount");
String paymentStartDate = request.getParameter("paymentStartDate");
String paymentExpiryDate = request.getParameter("paymentExpiryDate");
String paymentDescription = request.getParameter("paymentDescription");
String paymentState = request.getParameter("paymentState");


//Integer.parseInt()
// get old Payment object from session
Payment newPayment = new Payment(Integer.parseInt(paymentID),Integer.parseI nt(clientID),paymentType,Double.parseDouble(paymen tAmount),Date.parseDate(paymentStartDate),Date.par seDate(paymentExpiryDate),paymentDescription,Boole an.parseBoolean(paymentState));
// PaymentDescription,Double.parseDouble(unitPriceSma ll),Double.parseDouble(unitPriceMedium), Double.parseDouble(unitPriceLarge));
// update Payment information
PaymentDB.addRecord(newPayment);

// over-write Payment object in session
request.getSession().setAttribute("payment",newPay ment);
request.getSession().setAttribute("payments",Payme ntDB.readRecords());

RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/Admin/payments.jsp");
dispatcher.forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
doGet(request, response);
}


}


Problem lies here:


Code: ( text )
Payment newPayment = new Payment(Integer.parseInt(paymentID),Integer.parseI nt(clientID),paymentType,Double.parseDouble(paymen tAmount),Date.parseDate(paymentStartDate),Date.par seDate(paymentExpiryDate),paymentDescription,Boole an.parseBoolean(paymentState));



I need help why it's like that?
Thanks
May 28 '08 #1
Share this Question
Share on Google+
5 Replies


BigDaddyLH
Expert 100+
P: 1,216
This has got nothing to do with JSP/servlets. You are just assuming a method exists when it doesn't. Class java.util.Date doesn't have a method called parseDate. The proper was to parse dates is to use DateFormat or SimpleDateFormat:

http://java.sun.com/javase/6/docs/ap...ateFormat.html
May 28 '08 #2

100+
P: 274
thanks for replying.
I am trying this now
Expand|Select|Wrap|Line Numbers
  1. Payment newPayment = new Payment(Integer.parseInt(paymentID),Integer.parseInt(clientID),paymentType,Double.parseDouble(paymentAmount),DateFormat(paymentStartDate),DateFormat(paymentExpiryDate),paymentDescription,Boolean.parseBoolean(paymentState)); 

still getting error
May 28 '08 #3

BigDaddyLH
Expert 100+
P: 1,216
Set this code aside and try to write a simple program -- only a few lines long -- that tries to parse a String into a Date. Note that DateFornat and SimpleDateFormat are classes, so what you wrote makes no sense.
May 28 '08 #4

100+
P: 274
thanks, I got what you mean . problem was I did not knew how to work with that class. I was expecting it would be already defined like int.parseInt().
thanks buddy
May 28 '08 #5

BigDaddyLH
Expert 100+
P: 1,216
thanks, I got what you mean . problem was I did not knew how to work with that class. I was expecting it would be already defined like int.parseInt().
thanks buddy
It's important to read the API rather than guessing. Guessing has a low success rate.

http://java.sun.com/javase/6/docs/ap...ateFormat.html
May 28 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.