On 18/10/12 13:28, John English wrote:
On 17/10/2012 21:40, david myers wrote:
John,
If you have a look at the java Gregorian calendar class
(http://docs.oracle.com/javase/7/docs/api/java/util/GregorianCalendar.html#GregorianCalendar(java.util.TimeZone,%20java.util.Locale)
It has a constructor for setting the timezone and locale. I imagine you
could insert this quite easily into the code on your interface, grabbing
the time from the DB and using your interface to convert it to the
desired locale, I imagine you can probably inject the same as a user
defined function into derby itself.
Yes, this is true. However, the problem then arises that the column at
the DB end doesn't contain strings like "feb" (or "fev" if using
French) so I can't filter the results by adding "where usr_time like
'%feb%'" to the query. What I'm stuck with is localising the results
that come out of the DB, not localising them afterwards.
Best idea I've had so far is to add a locale column to my table of
users and select that so I can pass it as a parameter to my TimeFormat
function. The problem with that is that I will end up multiplying the
number of rows returned by the view by the number of users, which at
the moment amounts to a few hundred.
What I really need is a "create temporary view", or better still a way
to smuggle a value inside the Connection that I use for the query that
could be picked up inside TimeFormat. Sigh.
Thanks for trying anyway!
Could you not set a log on trigger for a user to create a view of the
principle table and have it convert the times automatically into the
locale for that user?
Bearing in mind that gregorianCalendar has a constructor that includes
not just a timezone value, but a value for a locale also.
Maybe you should insist on having the "english" locale installed by
default (probably already done by most OSs) and then in your code using
something like....
<pseudo code>
String yourMonth = new String([value set by user]);
String sqlQueryWhereClause = "where usr_time like '%" +
yourMonth.toLowerCase(Locale.English) + "'%";
//now build the rest of your query from here....
</pseudo code>
I guess the only thing you need to be aware of is the turkish locale,
something strange with the "i" character.
I don't know if that is going to help you or not !
David