Welcome to my blog, hope you enjoy reading
RSS

Tuesday 19 November 2013

How to convert java.util.Date to String in GWT client side

How to convert java.util.Date to String in GWT client side


In GWT we use SimpleDateFormat in Client side it throws the compiling error.
so use DateTimeFormat instead of SimpleDateFormat.


 String currentdate="";
  try 
  {
DateTimeFormat dateFormat =DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss");
currentdate= dateFormat.format(new Date());
} catch (Exception e) 
{
e.printStackTrace();
}

0 comments: