Timestamp系もJavaConnectorでJavaまかせ

Timestampの処理も、おもいっきりJavaまかせです。はっきりいって、Javaの標準関数に渡して、そのままスルー。なんだか、ピンはね業みたいなプログラムです。
ちなみに、Javaネクターは、これをJarでかためて、ALINOUS_HOME/libにぶち込めば終わりです。あとは、Alinous-Coreが勝手に認識します。


package org.alinous.lib;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;

import org.alinous.jdk.IAlinousFunction;

public class TimestampFunctions implements IAlinousFunction
{

public String[] getFunctions()
{
return new String[]{"format", "now"};
}

public String getPrefix()
{
return "Timestamp";
}

// YYYY '年' MM '月' DD '日' HH:MM:SS
public String format(String timestamp, String format)
{
Timestamp tm = Timestamp.valueOf(timestamp);

SimpleDateFormat formatter = new SimpleDateFormat(format);

return formatter.format(tm);
}

public String now()
{
long mill = System.currentTimeMillis();

return new Timestamp(mill).toString();
}
}