Matlab環境から呼び出されたJavaコードを書いています。オブジェクトを返します.DATEオブジェクトです。このDateオブジェクトをさらに処理するために使用します。さらなる処理のために日付オブジェクトをキャッチ
import java.io.IOException;
import org.apache.commons.net.TimeTCPClient;// third party class
import java.util.Date;
public final class TimeClient
{
public static final Date timeTCP(String host) throws IOException
{
TimeTCPClient client = new TimeTCPClient();
try
{
// We want to timeout if a response takes longer than 4 seconds
client.setDefaultTimeout(4000);
client.connect(host);
Date t=client.getDate();
System.out.println(t);
return t;
}
finally
{
client.disconnect();
}
}
public static final void main(String[]args)
{
{
try
{
timeTCP(args[0]);
}
catch (IOException e)
{
e.printStackTrace();
System.exit(1);
}
}
}
}
これはcode.IはM-ファイルとして保存された上記のjavaを呼び出して、私のMatlabのコードです
function t = gettime()
import java.io.IOException
import java.util.Date
import org.apache.commons.net.TimeTCPClient
import MATLAB.project.*
tc= TimeClient
tc.main('time-a.timefreq.bldrdoc.gov')
end
あなたは私を救助するために再び来ました。 – shree