-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi!
I want to show in listitems values from database, contained date and time in BigInt format which I mapped to Long.
value example:1261057621000
desired format: 17.12.2009 18:07
I tried this approach:
<zscript> import java.text.SimpleDateFormat; import java.util.Date; public String transform(Long lng) { SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Date dtime = new Date(lng); System.out.println(dtime.toString()); return format.format(dtime); } </zscript>
Is there any appropriative solution?
ok, I solve it :)
public class LongDateConverter implements TypeConverter{ public Object coerceToBean(Object val, Component comp) { // TODO Auto-generated method stub return null; } public Object coerceToUi(Object val, Component comp) { DateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Long time = (Long) val; Date dtime = new Date(time*1000); //1000 nedded for Moodle values return format.format(dtime); } }
usage: <listcell label="@{zx1.timeopen, converter='mypack.converter.LongDateConverter'}" />
Asked: 2009-12-17 09:11:01 +0800
Seen: 669 times
Last updated: Dec 17 '09