473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

274 100+
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
5 3454
BigDaddyLH
1,216 Expert 1GB
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
creative1
274 100+
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
1,216 Expert 1GB
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
creative1
274 100+
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
1,216 Expert 1GB
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

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

Similar topics

1
by: Sergio | last post by:
I want to execute a method of one applet from one page HTML. If I execute the method that it reads from rows from init() all it works. f instead I execute the method through...
3
by: Peter Afonin | last post by:
Hello: In VB I was using InStr function to determice whether some string exists within another string. How would I do it in C#? For instance, I have a long string created by StringBuilder. I...
0
by: Robin Tucker | last post by:
I'm localizing and need to find all string literals in my source code. I don't want to find any of the literals that will end up in resources however. As I don't use the "Me" keyword, I know...
6
by: bobueland | last post by:
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says
2
by: Bryan_Cockrell | last post by:
Hi World, I am extracting text from an ebcdic header using dd in the cygwin environment (bash/ksh) as below in order to rename the file to something intelligent. I'm using a specific string...
2
by: csharpula csharp | last post by:
Hello, I want to implement "wild card" search by searching files with *name* criteria. What is the best way? Should I do foreach to all names or maybe there is a better way? *** Sent via...
13
by: nishit.gupta | last post by:
Is their any fuction available in C++ that can determine that a string contains a numeric value. The value cabn be in hex, int, float. i.e. "1256" , "123.566" , "0xffff" Thnx
2
by: Hetal | last post by:
Hi... I am a newbie VB.NET developer and i am looking at working with ADO.NET rather than ADO. In one of our native VB application with ADO, we used to create 1 connection object and that would...
3
by: shapper | last post by:
Hello, I have two arrays of strings, s1 and s2: s1 = "london, lisbon, paris, newyork" s2 = "lisbon, yellow, France" s2 will have only one item included in s1.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.