For example, the following class displays members of the time dimension as "01-JAN-2005".
public class TimeMemberFormatter implements MemberFormatter {
public String formatMember(Member member) {
SimpleDateFormat inFormat =
new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.S");
SimpleDateFormat outFormat =
new SimpleDateFormat("dd-MMM-yyyy");
try {
Date date = inFormat.parse(in.getName());
return outFormat.format(data);
} catch (ParseException e) {
e.printStackTrace();
return "error";
}
}
}
@author hhaas
@since 6 October, 2004
|
|