Welcome to Dream.In.Code
Become a Java Expert!

Join 149,519 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,371 people online right now. Registration is fast and FREE... Join Now!




date field retrieval

 
Reply to this topicStart new topic

date field retrieval, date retrieval from rms using j2me

sharmi
25 May, 2007 - 02:23 AM
Post #1

New D.I.C Head
*

Joined: 25 May, 2007
Posts: 1


My Contributions
I have a problem with the date field retrieval it is not displaying the date stored it is showing some message like textfiels@333etc i happend to c a similar question posted i tried to aplly the remedial measures suggested there but it does not work please help


The code that im working on is as shown
mainForm = new Form("Add");
StringItem msg = new StringItem("","Add the details");
mainForm.append(msg);
add = new Command("ADD",Command.OK,1);
mainForm.addCommand(add);
search = new Command("Search",Command.BACK,2);
mainForm.addCommand(search);
delete=new Command("delete",Command.SCREEN,3);
mainForm.addCommand(delete);
mainForm.setCommandListener(this);
//display = Display.getDisplay(this);

addForm = new Form("Details");
Name = new TextField("Name",null,50,TextField.ANY);
Occassion = new TextField("occassion:",null,10,TextField.ANY);
//DateField Date = new DateField("DOB: ", DateField.DATE);
Phoneno = new TextField("Phone number:","",50,TextField.PHONENUMBER);
//Date.setDate(new Date());
//DateField d= new DateField("dd/",DateField.DATE);

//dateField = new DateField( null, DateField.DATE );
//addForm.append( d );
date=new DateField("dd",DateField.DATE);
// MM=new TextField("MM/","",50,TextField.PASSWORD);
addForm.append(Name);
addForm.append(Occassion);
//addForm.append(Date);
addForm.append(Phoneno);
//addForm.append(DateField);
//addForm.append(MM);
addForm.append(date);
//DateField Date = new DateField("Your DOB: ", DateField.DATE);
//Date=DateField.getDate().String.valueOf(Date);


addLoginInfo = new Command("save",Command.OK,1);
back = new Command("Back",Command.BACK,2);
addForm.addCommand(addLoginInfo);
addForm.addCommand(back);
addForm.setCommandListener(this);
deleteForm=new Form("Delete");
deleteText=new TextField("Name:",null,50,TextField.ANY);
deleteForm.append(deleteText);
deleteLoginInfo=new Command("delete",Command.OK,1);
deleteForm.addCommand(deleteLoginInfo);

deleteForm.addCommand(back);
deleteForm.setCommandListener(this);
searchForm = new Form("Search");
searchText = new TextField("Name:",null,50,TextField.ANY);
searchForm.append(searchText);
searchLoginInfo = new Command("Search",Command.OK,1);
searchForm.addCommand(searchLoginInfo);
searchForm.addCommand(back);
searchForm.setCommandListener(this);
result = new StringItem("","");
searchForm.append(result);
newForm= new Form("Data Saved");
StringItem msg1 = new StringItem("","Data added successfully");
newForm.append(msg1);
new1Form= new Form("Data Saved");
StringItem msg2 = new StringItem("","Data deleted successfully");
new1Form.append(msg2);
back1=new Command("Back1",Command.BACK,2);
newForm.addCommand(back1);
newForm.setCommandListener(this);
}

if (cmd==add){
Name.setString("");
Occassion.setString("");
Phoneno.setString("");
date.setDate(new Date( )) ;
//MM.setString("");
//Date.setString("");
display.setCurrent(addForm);
}
private void search(String keyword) {
try {
byte[] entry;
int length;
String Name;
String Occassion;
String date;
String phoneno;
boolean found=false;
for (int i = 1; i <= recStore.getNumRecords(); i=i+3) {
entry = new byte[recStore.getRecordSize(i)];
entry = recStore.getRecord(i);
Name= new String(entry);
if(Name.equals(keyword)){
entry = new byte[recStore.getRecordSize(i+1)];
entry = recStore.getRecord(i+1);
Occassion = new String(entry);
entry = new byte[recStore.getRecordSize(i+2)];
entry = recStore.getRecord(i+2);
//Date = new String(entry);
//entry = new byte[recStore.getRecordSize(i+3)];
//entry = recStore.getRecord(i+3);
//status = new String(entry);

entry = new byte[recStore.getRecordSize(i+3)];
entry = recStore.getRecord(i+3);
date=new String(entry);
java.util.Date dt=(java.util.Date)date.getdate();
String stdate=dt.toString();
dt=date.getDate();
String eddate=dt.toString();

// Reportsave and ReportDB are another files written to save and retrieve data

recstore date = new recstoresave(Name.getString(), Occassion.getString(),
phoneno.getString(),

date);
reportIDs.addElement(new Integer(DB.addContactRecord(report.pack())));



result.setLabel("Result:");
result.setText("Occassion:"+Occassion+"Name"+Name+"phoneno"+phoneno+"date"+date);
found=true;
break;
}
}
if(!found){
result.setLabel("Result:");
result.setText("Not Found");
}
}
catch (Exception e) {
System.err.println(e.toString());
}
}


User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: Date Field Retrieval
26 May, 2007 - 12:21 PM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,101



Thanked: 25 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
don't forget to use [code ][ /code] tags around all code.

There is a lot of code here... mostly commented out, yet it is not an entire class, care to show us which line causing the problem?

also you are assigning the variable dt twice, before using it, is there a reason for this?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 08:14PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month