I want to include a timeout duration, like "25 seconds" or "1 minute", in a user-facing message. Is there a way to do this in gwt?
From this resource, I know that I can do dates like this:
#DefaultMessage("Last update: {0,date,medium} {0,time,medium}")
String lastUpdate(Date timestamp);
but there doesn't seem to be anything like:
// hypothetical
#DefaultMessage("Requests time out after {0,duration}")
String timeout(Interval duration); // also Interval is a JodaTime concept...
Is there?
JodaTime still isn't really available for GWT (there are/were several projects, but unfortunately none ever really established itself). I hope someday we'll see JavaSE 8's new Date API in GWT!
Until then, I would use the following approach:
Storing the duration as a number of seconds (or milliseconds if required).
Creating one internationalized message for 0-59 seconds, one for 1-59 minutes, and one for 1-... hours.
Each of these messages can use Plural Forms.
Selecting the best message (seconds/minutes/hours) programmatically.
I have a datalogger that produces a CSV file containing UTC time and 4 parameters. The UTC time is logged ABOUT every 30ms followed by the 4 parameters. The problem I have is 2 fold:
1) The CSV file is potentially huge if I run the datalogger for even an hour.
2) The UTC time is not exactly every 30ms.
In my simple design for a replay of the data I had planned to load the file, split each entry at character "'" then assign the values in a loop though the UTC time value and then load the 4 parameters, but with the file so large I am concerned it wont work or will be very slow. I am new to java and am not sure if the there is a better way to handle so much data (I suspect there is!).
My plan to loop through and repeat he filling of 4 variables for the parameters wont work as the UTC entries are not exact. I had planned to take a decimal place off the data, but that clearly looses me fidelity in the replay of my data. I want to be able to construct a "timeline" in my application to allow play pause stop style functionality hence my problem handling the UTC time.
Here is a sample of some of the data when the time is pretty tight, this isnt always the case:
,13:35:38.772,0,0,0,0.3515625
,13:35:38.792,0,0,-0.0439453125,0.3515625
,13:35:38.822,0,0,0,0.3515625
,13:35:38.842,0,0,0,0.3515625
,13:35:38.872,0,0,0.0439453125,0.3515625
,13:35:38.892,0,0,0,0.3076171875
,13:35:38.922,0,0,0,0.3076171875
,13:35:38.942,0,0,0,0.3076171875
,13:35:38.962,0,0,0.0439453125,0.3515625
,13:35:38.992,0,0,0,0.3515625
,13:35:39.012,0,0,0,0.3076171875
,13:35:39.042,0,0,-0.0439453125,0.3076171875
,13:35:39.072,0,0,0,0.3515625
,13:35:39.092,0,0,0,0.3515625
,13:35:39.112,0,0,0.0439453125,0.3076171875
,13:35:39.142,0,0,0,0.3515625
,13:35:39.162,0,0,0,0.3076171875
,13:35:39.192,0,0,0,0.3515625
,13:35:39.212,0,0,0,0.3076171875
,13:35:39.242,0,0,0,0.3515625
,13:35:39.262,0,0,0,0.3076171875
I realise this is a broad question, but I am looking for a general steer in how to tackle the problem. Code is welcome, but I am expecting to have to ask more questions as time goes on.
Thanks for the help;
Andy
Hi I am very new to Android Development. I want to pick the country name based on the current time of the particular mobile, while clicking the button. How can i do it? Any body tell me? Thanks in advance.
It seems difficult considering most timezones contain multiple countries (and countries multiple timezones as well).
See: Android: Is there a way to get timezone for Country name?
Per above, the closest you'll get comes from here:
For getting the time zone, check out the "O" and "T" format specifiers
of the date() function. "O" will give you the Difference to Greenwich
time (GMT) in hours (your time zone offset) and "T" will give you the
time zone abbreviation like "EST" for Eastern Standard Time.
e.g. <?php echo date("T"); ?> will give you the executing PHP script timezone, for the user timezome you can pass their date/time as the second argument.
I don't think thats possible because you can have MANY MANY countries on the same time. For example, just take the GMT+/-0 time zone, you'll have England, France, Spain, Portugal, and a few others you can get from the african countries. You can't do it like that.
What i'd suggest is to implement a GEOIP location using for example: MaxMind GEOIP. You have some very powerful tools available in PEAR for that and it took me about 4 hours to setup the library, understand the code and do the code to query. I was querying for IPs and countries and even states/provinces in less than 4 hours. You can't get faster than that unless your a genious :)
Is it possible in Java without any extra library to internationalize distances?
I mean it is possible to handle that with date, time, currencies, numbers...
I would have expected to find a NumberFormat.getDistanceInstance or something.
Is there something like that already embedded or should i make my own internationalization system for distances (mostly miles vs kilometers)
I would love to hear about such formatter but unfortunately I never did. The problem is, there is no such data in CLDR yet, so it is not to easy to do.
That is to say that people actually think about this for quite a while – see ICU's Measure class. Unfortunately for now, it seems as close you can get is to determine measurement system – see LocaleData and LocaleData.MeasurementSystem.
After that you are on your own. You would need to leave this for translators (they need to actually translate units as well as formatting pattern).
No, there's nothing in the JDK to i18n distances, weights and most other measurement units, except for calendars (I know it's not really a unit, but the lunar calendar is quite different from the Gregorian calendar). Even OSs don't have that kind of information.
The only i18n you can do with time, currencies, numbers is the formatting. There's no feature to change the measurement unit.
So you'll need to build your own for distances :S.
Just asking, and how would you go about doing this.
I know there is ways to get an overall percentage to inform users of the download's progress, but I haven't a clue on how I can do the similar for time.
E.g. "Time until download finishes: 5 minutes".
All I know is percentages, writing the bytes written then dividing it by the length and turning it into a percentage (if I recall correctly, haven't done the above for a few months, so I'm rusty and very forgetful)
Thanks, out of curiosity.
For a completely linear model, you simply divide the number of bytes left to download by the so-far-average download speed:
double avgSpeed = (double) bytesDownloaded / timeElapsed;
double timeLeft = byteLeftToDownload / avgSpeed;
If you stick to milliseconds everywhere, timeLeft will contain the estimated number of milliseconds until the full file is downloaded.
To output that properly in terms of hours and/or minutes and/or seconds, I suggest you have a look at
How to convert milliseconds into human readable form?
Yes, you can.
No, there's nothing "built-in".
And there are actually (at least) two parts to your question:
1) How do I determine the time?
2) How do I display it?
Suggestion:
Google for "Java status bar", and look at some code that might do what you're looking for.
Suggestion:
Look at MS Vista's "time remaining" algorithm. Whatever Vista is doing - don't do that ;)