> Folks, do you have solution to third of the above steps? I am stuck
> myself on this issue.

Look at the javadoc for DateTimeFormat, you'll find that the get*Formta
() methods return a formatted already instantiated with a pattern and
"The pattern for this format is predefined for each locale"

So the formatters returned by those method do exactly what you need.

Cheers,

Salvador

On Apr 23, 11:10 am, Sushrut Bidwai <[email protected]> wrote:
> Hi.
>
>  This is what I understand from Priyas input. Though I dont know the
> solution myself.
>
> 1. Take timestamp from client side and send it to server. (easy)
> 2. Store this in database (easy)
> 3. Display it back to clientside is client-side format. IE Some
> clients may be using HH:mm some may be on hh:mm format. So while
> displaying retrieve information about the format that needs to be
> displayed and then format the db timestamp accordingly for display.
>
> Note, I dont think Priya wants to store the timestamp in db in diff
> formats as we simply store the milliseconds from epoch.
>
> Folks, do you have solution to third of the above steps? I am stuck
> myself on this issue.
>
> On Apr 23, 9:21 am, Sebastien <[email protected]> wrote:
>
> > Hi,
>
> > Be careful, the use of Date instance between client side and server
> > side takes in account the time difference between geographical areas.
> > Then if your client lives in USA whereas your web server is in Europe
> > (my case), the formated date is not the same. There is al least 6
> > hours in less ... But the long value in the java.util.Date instance is
> > the same; it is the number of milliseconds since 01 Jan 1970 based on
> > the UTC.
>
> > --
> > Seb
>
> > On 23 avr, 05:18, Arthur Kalmenson <[email protected]> wrote:
>
> > > > In that case, I think
> > > > that the only way to get the user's preference is to ask them.
>
> > > Building on this, if you want the user to choose their own format, let
> > > them do so. Then, when you pull the date from the database (stored as
> > > a date, not a String), you can format that Date object using GWT's
> > > DateTimeFormat 
> > > (http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/g...)
> > > in the format the client request it.
>
> > > --
> > > Arthur Kalmenson
>
> > > On Wed, Apr 22, 2009 at 11:28 AM, Ian Bambury <[email protected]> 
> > > wrote:
> > > > Priya, you can't do what you are asking.
> > > > If you are storing a datestamp in a database then you will probably be
> > > > storing the number of milliseconds since 01 Jan 1970. Whatever format 
> > > > you
> > > > pass to the database, if it can understand it, it will convert it to 
> > > > that.
> > > > In a lot of cases, it will guess wrong, yyyy-mm-dd HH:mm:ss is usually 
> > > > safe.
> > > > If you are storing it as text, then that is different. In that case, I 
> > > > think
> > > > that the only way to get the user's preference is to ask them.
> > > > Ian
>
> > > >http://examples.roughian.com
>
> > > > 2009/4/22 priya <[email protected]>
>
> > > >> I got what you explained.
>
> > > >> I am sending client side date as follows:
>
> > > >> Date executionDate = new java.uti.Date();
>
> > > >> and storing id database same as u told like:
>
> > > >> Timestamp executionTimestamp = new Timestamp(executionDate.getTime
> > > >> ());
>
> > > >> But my problem is that I want to store the time in the format same as
> > > >> client side.
> > > >> Means if client side time is 03:45PM then it should save 03:45 and not
> > > >> 15:45.
> > > >> And if client side time is 15:45 then it should save 15:45.
>
> > > >> But I am getting time as 15:45 if my system time is 03:45PM.
>
> > > >> I hope u got my problem.
>
> > > >> Please help me to solve this problem.
>
> > > >> On Apr 22, 6:08 pm, Salvador Diaz <[email protected]> wrote:
> > > >> > > but if client side time is in 12hr format then also I am getting 
> > > >> > > 24hr
> > > >> > > format time.
>
> > > >> > What do you mean by that ? Could you be more clear ? I want to help
> > > >> > you but I need to know what it is that you're not understanding from
> > > >> > what I told you.
>
> > > >> > Maybe paste some code snippets that'll show me how you're tackling
> > > >> > this problem because time formats have nothing to do with storing a
> > > >> > timestamp.
>
> > > >> > Normally this is what you should do:
>
> > > >> > //client-side: instantiate a date and send it to server to be stored
> > > >> > Date executionDate = new Date();
> > > >> > SomeRPCAsyncInterface.storeDate(executionDate, someCallback);
>
> > > >> > //server-side:
> > > >> > public void storeDate(Date executionDate){
> > > >> >   Timestamp executionTimestamp = new Timestamp(executionDate.getTime
> > > >> > ());
> > > >> >   //the code to persist the timestamp, (JDBC, hibernate, or whatever
> > > >> > you use to store things in your database)
>
> > > >> > }
>
> > > >> > So there it is, no need to use formatters anywhere.
>
> > > >> > I hope it's clearer now. If it isn't you should familiarize yourself
> > > >> > with the way the Date object works and its API
>
> > > >> > Good luck,
>
> > > >> > Salvador
>
> > > >> > On Apr 22, 2:49 pm, priya <[email protected]> wrote:
>
> > > >> > > Yeah I can do that..
> > > >> > > but if client side time is in 12hr format then also I am getting 
> > > >> > > 24hr
> > > >> > > format time.
>
> > > >> > > For 24hr format time it is giving correct time.
>
> > > >> > > I want to save the time same as client time (client system time).
>
> > > >> > > How can I do this?
>
> > > >> > > On Apr 22, 5:32 pm, Salvador Diaz <[email protected]> wrote:
>
> > > >> > > > Well then pass a java.util.Date object instantiated at the
> > > >> > > > client-side
> > > >> > > > through a RPC and store it. No need to format anything.
>
> > > >> > > > On Apr 22, 2:10 pm, priya <[email protected]> wrote:
>
> > > >> > > > > I don't want server side date time.
> > > >> > > > > I want to store client side date time as Timestamp in database.
>
> > > >> > > > > On Apr 22, 4:20 pm, Salvador Diaz <[email protected]> 
> > > >> > > > > wrote:
>
> > > >> > > > > > Sorry but I'm still not understanding exactly what you're 
> > > >> > > > > > trying
> > > >> > > > > > to
> > > >> > > > > > do.
>
> > > >> > > > > > I got the part where you're saying that you want to store a
> > > >> > > > > > timestamp
> > > >> > > > > > in a database. But is it the server-side time or client-side
> > > >> > > > > > time ?
>
> > > >> > > > > > Either way, you shouldn't need to format dates to do that, 
> > > >> > > > > > just
> > > >> > > > > > pass
> > > >> > > > > > the java.util.Date object in your RPCs and then instantiate 
> > > >> > > > > > your
> > > >> > > > > > timestamp from the date object before storing it in the
> > > >> > > > > > database.
>
> > > >> > > > > > What are you're storing those timestamps for ? Because 
> > > >> > > > > > depending
> > > >> > > > > > on
> > > >> > > > > > that, you might not want to trust the dates handed to you by
> > > >> > > > > > your
> > > >> > > > > > clients and instead use the date of the actions you want to
> > > >> > > > > > timestamp
> > > >> > > > > > in the server side of your code.
>
> > > >> > > > > > On Apr 22, 12:38 pm, priya <[email protected]> wrote:
>
> > > >> > > > > > > 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
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to