I want to send current date time as String at server side and then I am converting this String to java.sql.TimeStamp to store into database.
But I want to store the system date and time. And to format this date time at client side I want whether the system time is in 12hr or 24hr format. According to that I am using DatTimeFormat. Is there any other way to do this? I want to use this in my GWT application. On Apr 22, 3:25 pm, Salvador Diaz <[email protected]> wrote: > > So I have to know the 12hr or 24 hr format for system time to use the > > DateTimeFormat. > > No you don't. You decide what format you want to display and use the > corresponding pattern in the getFormat method. > > If you want to display a date in the 24h format, you have to do: > Date myDate = new Date(); > String formattedDate = DateTimeFormat.getFormat("dd/MM/yyyy > HH:mm").format(myDate); > > If you want to display it in the 12h format you do: > String formattedDate = DateTimeFormat.getFormat("dd/MM/yyyy > hh:mm").format(myDate); > > But please tell us what you're trying to do exactly, maybe I'm missing > something. > > On Apr 22, 12:15 pm, priya <[email protected]> wrote: > > > Thanks for reply.. > > I want to know the format of the time at client side whether it is > > 12hr or 24hr.. > > because I am using: > > > DateTimeFormat to format my date. > > It is given that DateTimeFormat.getFormat("dd/MM/yyyy HH:mm") provides > > 24 hr format and > > DateTimeFormat.getFormat("dd/MM/yyyy hh:mm") provides 12hr format. > > (Note HH and hh). > > > I am doing this at client side. > > So I have to know the 12hr or 24 hr format for system time to use the > > DateTimeFormat. > > > how can i get this? > > I hope u got my question.. > > > On Apr 22, 2:37 pm, Vitali Lovich <[email protected]> wrote: > > > > Not sure what your question is. Are you trying to format for display? > > > Are > > > you trying to parse input? Trying to determine something else? > > > > Formatting & parsing already done for > > > you:http://google-web-toolkit.googlecode.com/svn/javadoc/1.4/com/google/g... > > > > A hack (unless there's no better way) would be to use DateTimeFormat to > > > format a date so it displays a known time like year 0, month 1, day of > > > month > > > 1, hour 23, minute 0, second 0. Then search for the number 23 in the > > > formatted string - if it's there, you're on military time - otherwise > > > AM/PM. > > > > However, this obviously has downsides because it makes assumptions about > > > how > > > the locale formats the time (in particular assumes arabic numbers for time > > > format). > > > > On Wed, Apr 22, 2009 at 5:12 AM, priya <[email protected]> wrote: > > > > > Hi all, > > > > > In my GWT application I want to know the time format of the system > > > > time > > > > whether its 12 hr or 24hr at client side. > > > > > How can i get this? > > > > > Can anyone help me? > > > > > Its really urgent... > > > > > Thanks, > > > > Priya > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
