TC65 troubling with JAVA Date() class

Hi,

I work with TC65 on NetBeans and my program has to connect a TCP server. When it's connected, the server send to me current time and the modem execute ATCommand like :

String rep=at.send("AT+CCLK=\""+year+"/"+month+"/"+day+","+h+":"+m+":"+s+"\"\r");

A println function let me now this ATCommand worked. BUT! the current time in modem is not set ! And when i relaunch application, a println function at the program's top says the good date ! I use "new Date()" to have the current time, but i m wondering why AT+CCLK from JAVA doesn't work during the first execution. By the way, in ATcommand mode (by serial) AT+CCLK work immediately ! Thank you to help me ...

[867 byte] By [adesporta] at [2007-11-26 22:29:21]
# 1

When you execute the AT+CCLK in you Java Application, the TC65 is answering with "OK"?

My firmware uses the AT+CCLK too, and it works fine!

It connects to a DayTime server using a TCP connection, get the correct time, and sets it using the at+cclk.

By the way, why are u trying to use the "Date" class?

Fernando_Scarpina at 2007-7-10 11:33:17 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
Yes it answers "OK". The command works but i use Date class with Timer tasks and current time is not update...
AdrienDa at 2007-7-10 11:33:17 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
Could you post your code?
Fernando_Scarpina at 2007-7-10 11:33:17 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4

public void dateUpdate(Calendar cal) {

String year = String.valueOf(cal.get(Calendar.YEAR)).substring(2);

String month = String.valueOf(cal.get(Calendar.MONTH)+1);

if(month.length()==1)

month = "0".concat(month);

String day = String.valueOf(cal.get(Calendar.DAY_OF_MONTH));

if(day.length()==1)

day = "0".concat(day);

String h = String.valueOf(cal.get(Calendar.HOUR_OF_DAY));

if(h.length()==1)

h = "0".concat(h);

String m = String.valueOf(cal.get(Calendar.MINUTE));

if(m.length()==1)

m = "0".concat(m);

String s = String.valueOf(cal.get(Calendar.SECOND));

if(s.length()==1)

s = "0".concat(s);

try{

//System.out.println("Heure millis avant AT System & Date : "+System.currentTimeMillis()+"/"+new Date().getTime());

String rep=at.send("AT+CCLK=\""+year+"/"+month+"/"+day+","+h+":"+m+":"+s+"\"\r");

System.out.println("DATE:"+rep+" System : "+System.currentTimeMillis()+"/"+new Date().getTime());

}catch(ATCommandFailedException ex) {

System.out.println("ATCommand failed! "+ex.getMessage());

}

}

ATCommand answer printed ("rep") is good (right hour) but System.currentTimeMillis() or new Date() ares wrong ... After a modem reset and without use AT+CCLK new Stae() return godd hour ...

AdrienDa at 2007-7-10 11:33:17 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5

The "System.currentTimeMillis()" and "getTime()" of "Date" instances are dependent of what is set in TC65 (and you set it with AT+CCLK). If you set the time and after that, the System.currentTimeMilis() returns wrong values, them you may be setting the wrong time.

By the way, if you powered the ME down, the actual time and date will be lost.

Fernando_Scarpina at 2007-7-10 11:33:17 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 6
Yes but AT+CCLK command respons is OK and is like <AT+CCLK="GOOD DATE" OK>. when modem restart hour is memorized and time is set with the date "GOOD DATE" by command AT+CCLK send before restart ....
AdrienDa at 2007-7-10 11:33:17 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 7
Here is your answer: http://www.siemens-support.com/jive3/thread.jspa?threadID=19761&tstart=0
deepspacea at 2007-7-10 11:33:17 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 8
I'm having the same problem, but the link above no longer works. Anyone have an idea where I can find the information now?
EvilBroa at 2007-7-10 11:33:17 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 9
Yes, in my head ;)It's actually very simple: You'll need to calculate the difference between the real time and the java time, and save in in a long value. Then make a new time class that will give you the time taking in account the difference.
deepspacea at 2007-7-10 11:33:17 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 10

> Yes, in my head ;)

I'll contact my head-hunting-cannibal-for-hire then...

>It's actually very simple: You'll need to calculate the

> difference between the real time and the java time, and

> save in in a long value. Then make a new time class that

> will give you the time taking in account the difference.

Thanks. I will note that it is stupid that this is the solution. Why on earth did they ever decide not to be able to set the time properly... *sigh*

Message was edited by:

EvilBro

EvilBroa at 2007-7-10 11:33:17 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 11
> Thanks. I will note that it is stupid that this is> the solution. Why on earth did they ever decide not> to be able to set the time properly... *sigh*Well, there are many stupid things in these modules, get over it ;)
deepspacea at 2007-7-10 11:33:17 > top of Java-index,Java Mobility Forums,Java ME Technologies...