Postal codes

Hello

I am fairly certain this has been discussed before.

I need ot format addresses and specifically postal codes so that not only our US post office is happy with a specific address/zip code so is the post office of the remote country that the form letter is going to.

I know this has to have been solved many times.I would think some form of a destination resourse file would be appropriate. Not sure how it would all fit together.

One problem that I am failing to understand the postal code comes out the the DB as a string appropriate to the destination country ( formatting "-" removed.) I need to put the hyphens back in a country appropriate way. Since all the postal codes so far are numbers with hyphens as formatting.I thought of using the NumberFormat class to format my postal code. But what about countries that have alpha characters in thier postal code.

I know I am missing something obvious. Not sure what.

Could someone point me in the right direction.

[1016 byte] By [cookepa] at [2007-11-27 5:18:59]
# 1

My approach would be to store the postal codes as is, and not to remove hyphens or spaces or any other punctuation. Then you don't have to worry about putting the punctuation back when you want to use the postal codes, and you don't have to worry about how Luxembourg formats their postal codes.

Both Canada and the UK have letters in their postal codes, and spaces too. I'm surprised you haven't encountered them yet.

DrClapa at 2007-7-12 10:42:15 > top of Java-index,Desktop,I18N...
# 2
The fact that some countries' postal codes contain letters is already a strong argument to store them as string. Furthermore, some postal codes have leading zeros, eg something like 00123. In this case, if it's a number, you'll get 123 instead. This is quite annoying for the post office
horiniusa at 2007-7-12 10:42:15 > top of Java-index,Desktop,I18N...
# 3

In the beginning we were just US 5 digit postal code then when they went to 9 digit us. some one decided the the formatting hyphens needed to be removed. Now we are sending letters to Canada where the hyphen is after the 3rd digit. There are plans for other countries.

I'll see if the architect is willing to revisit stripping out the country specific postal code formatting as this is relevant data. Are there any other options.

cookepa at 2007-7-12 10:42:15 > top of Java-index,Desktop,I18N...
# 4
It seems to me that the US postal codes contain two leading letters, like CA, IL, etc. Aren't they a part of postal code for you?
horiniusa at 2007-7-12 10:42:15 > top of Java-index,Desktop,I18N...
# 5
Actually Canadian postal codes have a space in the middle, not a hyphen. Like this: "M5W 1E6".And horinius, those are state codes (California is CA and so on). They aren't part of the postal code, they are a separate data item.
DrClapa at 2007-7-12 10:42:15 > top of Java-index,Desktop,I18N...