Format a numeric cell with Jakarta POI using Locale - format

Hy,
I need to set a format for a numeric cell(decimal separator....) in excel using Jakarta POI and a Locale. What I need is find a method which formats a numeric cell in excel without having to specify a hardcoded format like #,##0.000", just a Locale(I think Java already internally uses specific formats for numerics values according to a Locale). Is there one?
For example, what I do not need is the next(because here its specifying a hardcoded format):
cellStyle.setDataFormat(hssfDataFormat.getFormat("#,##0.000"));
Thanks

Related

How can I get the DateLastModified as an integer when filenames may contain UTF8 characters?

I'm writing Lua (5.3) in a Windows environment; the result will be used in many countries so file handling has to cater for multiple locales (which rules out the lfs and Penlight libraries) and also many date formats (as selected by the user).
I'm accessing files using luacom and Microsoft FileObject, which eliminates problems with file names, but I'm having difficulty with the DateLastModified property, which is returned in text.
I need to compare the DateLastModified for many hundreds of files to determine which is the latest.
One technique I've considered would involve temporarily setting (via the registry) the PC's Short Date format to something predictable that can be simply parsed such as "yyyy-MM-dd" (and resetting it afterwards) but I'm instinctively averse to messing with the user's registry settings, especially those that have ramifications outside my program.
I could copy each file to a temporary file with a name that allows lfs to get the modification data as an integer number of seconds, but that would seriously impact the run-time of what's supposed to be a fairly basic utility.
Is there a solution I've overlooked, or am I going to have to choose the least worst option? Note: I'm quite restricted in the libraries available in the target environment.
Although the default behaviour of Luacom is to return a Date as a text string (based on the current locale), it is possible to modify this behaviour:
3.4.6 DATE type
When converting from COM to Lua, the default behavior is to transform DATE values to strings formatted according to the current locale. The converse is true: LuaCOM converts strings formatted according to the current locale to DATE values. The script can change the conversion from strings to tables by setting the DateFormat field of the luacom table (the LuaCOM namespace) to the string "table". The table will have Day, DayOfWeek, Month, Year, Hour, Minute, Second, and Milliseconds fields. To return the conversion to strings, set the DateFormat field to "string". Be careful with this feature, as it may break compatibility with other scripts.
From Luacom documentation

Informatica v10.2 - Transformation for ASCII to EBCDIC

I need to convert data from ASCII to EBCDIC in an Informatica Transformation. I have attempted to use CONVERT_BASE in an expression using string datatypes for the currency data, but received a non-fatal error.
I've also googled a fair amount and have been unable to find a solution.
Has anyone encountered and been successful in a situation like this?
In Complex Data Exchange, you do not require a transformer to convert ASCII to EBCDIC format.
To change the encoding from ASCII to EBCDIC format, do the following:
LaunchContentMaster Studio
Go toProject > Properties > Encoding
Change the output encoding toEBCDIC-37 and the byte order toBigEndian.
Just in case if you need to transfer flat file from mainframe (EBCDIC) to Linux (ASCII) and preserve packed decimal fields / COMP-3 (i.e. do not unpack COMP-3); You can use a combination of PWX for VSAM/Sequential on the mainframe source, and PWX for Flat Files on the Linux machine for the target.
Create appropriate datamaps for the source, and for the target.
On the source side, use datamap functions to create a new field for each of the packed fields, as an unpacked value.
In the mapping, bring in the unpacked value ports, not the packed ones, as numerics.
In the datamap for the target, create only the packed fields.
In the mapping, map the (unpacked) numerics to packed numerics fields
PWX should handle the conversions for you.
Note that this includes operations on packed fields, so some signs may get converted from F to C.

PDF date field - one format, multiple valid inputs

I need to create a PDF with a date field that displays dates in the format dd.mm.yyyy. This field must be validated and should also accept inputs in other formats.
For example, users should be able to input dates in the form dd.mm.yy, which will then be expanded to dd.mm.20yy (MS Office apps like Excel do this).
Alternatively, selecting multiple valid formats would be an acceptable solution.
What currently happens:
If the date format of the field is set to dd.mm.yyyy, dd.mm.yy is rejected.
If the date format of the field is set to dd.mm.yy, dd.mm.yyyy is accepted (but formatted to dd.mm.yy).
The last behaviour is almost what i need, just with the wrong format.
Is there a way to do this without custom Javascript? If not, is there a way to still use the built-in formatting or do i have to rewrite everything in JS?
Unfortunately this is not achievable with Acrobat's built-in formatting.
One thing to add to your second bullet point: it trims the date down to .yy when you exit the field, but it still retains all four digits. When you click into the field, it will revert back to being .yyyy. That may or may not matter depending on how you're using it.
Regarding a custom validation, a quick Google search will yield an abundance of Javascript date validation scripts. Something like this could probably be quickly repurposed for your application.

MVC3 Cultures vs jQuery UI Date Formats

I am having a problem with an MVC3 application using a jQuery UI DatePicker object.
Within the MVC application, I ask the user to pick their required culture, i.e en-GB, which then formats all dates and currencies in the application in the british format.
I can then access the formatter code for this via Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern
However, the format returned for UK dates is: dd/MM/yyyy
To format the resulting data from the jQuery UI datepicker, I need to specify a date format. But for UK format dates, I need to specify the format as dd/mm/yy
The simple solution would be to just use Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern in my jQuery calls to format the date, but obviously this gives a formatting inconsistency as this is interpreted differently by jQuery UI (01/December/20112011 instead of 01/12/2011)
Is there any easy way around this?
The only way I can think of doing it is asking the user twice what format to display dates in?
I could think of another solution, but that's pretty low-tech, I'm not sure if that is the right way to do it:
var dateTime = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern;
var lowerCaseMonths = Regex.Replace(dateTime, "MM","mm");
var yearOnlyOnce = Regex.Replace(lowerCaseMonths, "yyyy", "yy");
Without "explaining variables" just
Regex.Replace(Regex.Replace(Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern, "MM","mm"), "yyyy", "yy")
Then I guess no matter in what format it is, dd/MM/yyyy MM/DD/yyyy dd-MM-yyyy etc, it should work out in jQuery.
Maybe someone has a better solution, but at least this seems better than asking for user input twice.
#System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern.ToLower().Replace("yyyy", "yy")

SQL Server 2005 Reporting Services language setting

Ok, i need to write a report in Arabic (ar-AS), the information for this report is in a database in English, with varchar columns (not nvarchar) with collation SQL_Latin1_General_CP1_CI_AS
The Language Settings for Reports and Report Designer only changes dates, currency, and numbers to the given language. I also need static text (column headers) on reports as well as the information being retrieved from the database to be formatted in the given language (Text right to left and characters mapped accordingly).
The text being converted is just names and addresses, nothing that would require Google translator.
Is it possible, I've come up empty so far.
My question is similar to this but i also want the English text to be formatted as Arabic.
The closest solution i found was using
SQL Analysis Services Translations
feature makes all this a thing of the
past, however. Assuming that your data
is moving through a cube, you can use
this great feature to localize all
your text, including captions, data,
etc
Also i don't think its possible to convert Arabic, Chinese, Japanese to English, since these languages have a different number of alphabets in their respective languages. Therefore there is no equivalent of the letter "A" in Japanese. No translation is possible for words that do not exist in a dictionary, such as names, and addresses.
The solution to this therefore is to store the data as nvarchar (SQL Server) in your database with the appropriate collation so that it can be extracted in the correct alphabet.
Good game world...
[edit]
- fixed grammar, cos adolf said so
what you need to do is create a .NET assembly and reference that in your application. In the assembly you can use a resource file (.resx) and create a function to grab the correct strings. Then wrap your static text in your report in expressions calling your function from your assembly, getting the correct text based on what locale you pass in.

Resources