i am getting date value as string from server in this way
Date = 13,01,2010
Time = 15,00
i have to display it on DateField , in the form of date , so that user can edit it .
thanks and regards
Arunesh
i am getting date value as string from server in this way
Date = 13,01,2010
Time = 15,00
i have to display it on DateField , in the form of date , so that user can edit it .
thanks and regards
Arunesh
J2ME does not support the DateFormat, You can just change it.
User can use the date application on the device.
Best regards,
i am using the following code for my work
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DATE,date);
cal.set(Calendar.MONTH,month);
cal.set(Calendar.YEAR,year);
cal.set(Calendar.HOUR,hour);
cal.set(Calendar.MINUTE,min);
long mili = cal.get(Calendar.MILISECONDS);
long m = Calendar.getTimeInMillis();
//dateField1.setDate(new java.util.Date(System.currentTimeMillis()));
System.out.println(cal.get(Calendar.DATE)+" "+cal.get(Calendar.MONTH)+" "+cal.get(Calendar.YEAR)+" "+cal.get(Calendar.MILLISECOND));
Date f = new Date(mili);
System.out.println("date provided by server = "+f);
but this line is showing error:
long mili = cal.get(Calendar.MILISECONDS);
if this works then i hope my work will be done.
thanks and regards
Arunesh
What error is it showing? That there is no such field as "MILISECONDS"? Check your spelling...![]()
Actally that is also an error (i have deleted it)
when i am using
Date f = new Date(cal.getTimeInMillis());
compiler is saying that "getTimeInMillis()" has protected scope
and
cal.get(Calendar.MILLISECOND)
return 0.
please help me
thanks and regards
Arunesh
i have used
long mili = cal.getTime().getTime();
instead of "gettimeinmilli" function , it worked for me
thanks
Arunesh
Well, yes. Check the JavaDocs. This is not a public method. Use:
What value are you expecting? You don't set the milliseconds, so they're zero. Remember that Calendar.MILLISECOND does not refer to the total number of milliseconds, but to the number of milliseconds within the second (between 0 and 999).Code:Date f = cal.getTime();
Graham.
my problem is not solved yet .. i don't know how it worked for the first time but now it is not working
problem statement is as follows
i get date and time from server in this format
Date = 30,01,2010
Time = 11,10
and i have to show this date and time in "Datefield", so what i did is as follows
int year = Integer.parseInt(date_in_Order[2]);
int month = Integer.parseInt(date_in_Order[1]);
int date = Integer.parseInt(date_in_Order[0]);
int hour = Integer.parseInt(time_in_Order[0]);
int min = Integer.parseInt(time_in_Order[1]);
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DATE,date);
cal.set(Calendar.MONTH,month);
cal.set(Calendar.YEAR,year);
cal.set(Calendar.HOUR,hour);
cal.set(Calendar.MINUTE,min);
now i have to get the date object from this calender so that i can display date in datefield in this form "dateField1.setDate(f);" where user will have privileged to do any modification in the date .
for the purpose of getting date object i used this "Date f = cal.getTime();" but it is not working .
i also tried
long mili = cal.getTime().getTime();
Date f = new Date(mili);
but this also did't worked for me .. it says " java.lang.IllegalArgumentException".
kindly guide me to solve the problem.
thanks and regards
Arunesh
1. "long mili = cal.getTime().getTime();" if i write this line i get Illegal exception
2. and "Date f = cal.getTime();" throws Illegal exception
the detailed description of exception is as follows
TRACE: <at java.lang.IllegalArgumentException>, Exception caught in Display class
java.lang.IllegalArgumentException
at com.sun.cldc.util.j2me.TimeZoneImpl.getOffset(), bci=76
at com.sun.cldc.util.j2me.TimeZoneImpl.getOffset(), bci=33
at com.sun.cldc.util.j2me.CalendarImpl.computeTime(), bci=295
at java.util.Calendar.getTimeInMillis(Calendar.java:1082)
at java.util.Calendar.getTime(), bci=13
at SmartComm.GroupSMSOptionsAction(), bci=839
at SmartComm.commandAction(SmartComm.java:847)
at javax.microedition.lcdui.ChoiceGroupLFImpl.uCallKeyPressed(), bci=271
at javax.microedition.lcdui.FormLFImpl.uCallKeyPressed(), bci=87
at javax.microedition.lcdui.DisplayableLFImpl.uCallKeyEvent(), bci=146
at javax.microedition.lcdui.Display$DisplayEventConsumerImpl.handleKeyEvent(), bci=30
at com.sun.midp.lcdui.DisplayEventListener.process(), bci=277
at com.sun.midp.events.EventQueue.run(), bci=179
at java.lang.Thread.run(Thread.java:619)
OK. One or more of the values you are setting into the Calendar's fields is invalid. Probably, the month is invalid. Exactly what are the values you are setting for each field? (You should get the code to display them, do not assume you know what they are.)