Results 1 to 14 of 14
Thread: Date formatting
- 05-08-2010, 02:02 PM #1
Member
- Join Date
- Dec 2009
- Posts
- 20
- Rep Power
- 0
Date formatting
Hi i have the next problem i save a form with dates to a sqllite database
the dates are viewed by the users as "07 mei 2010" (dutch format) but i need to save it as an american format "2010-05-07" otherwise search functions on date in sql lite don't work wel
exp: "select date from questions where date between '1 mei 2010' and '7 mei 2010'
gives the complete database.
between 2 mei 2010 and '7 mei 2010' works as it should.
with american formatting this problem is solved but how can i convert the american formatting back to dutch ?
i use netbeans with formattedtextfields
-
Are you able to set your Locale to Dutch? If so, then SimpleDateFormat should work for you as it would then be able to translate a Dutch date to other formats easily.
- 05-08-2010, 02:32 PM #3
Member
- Join Date
- Dec 2009
- Posts
- 20
- Rep Power
- 0
That's the problem there's no Dutch in the locale list
so i don't know how to solve this (just a beginner)
if i look here http://java.sun.com/j2se/1.4.2/docs/...ocale.doc.html Dutch is provided but i don't see it in Netbeans
Can this help me with my problem ?
Last edited by bikkerss; 05-08-2010 at 02:36 PM.
-
- 05-08-2010, 03:14 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,424
- Blog Entries
- 7
- Rep Power
- 17
- 05-08-2010, 03:30 PM #6
Member
- Join Date
- Dec 2009
- Posts
- 20
- Rep Power
- 0
how do i need to use this if i juse locale in netbeans i only seen canada till us but no dutch
-
What do you see if you run this?
Java Code:import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Locale; public class DutchDate { public static void main(String[] args) { Calendar today = Calendar.getInstance(); System.out.println(today.getTime()); Locale dutchLoc = new Locale("nl"); SimpleDateFormat sdf = new SimpleDateFormat("EEEE, MMMM dd, yyyy", dutchLoc); System.out.println(sdf.format(today.getTime())); } }
- 05-08-2010, 03:34 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,424
- Blog Entries
- 7
- Rep Power
- 17
- 05-08-2010, 03:46 PM #9
Member
- Join Date
- Dec 2009
- Posts
- 20
- Rep Power
- 0
- 05-08-2010, 03:49 PM #10
Member
- Join Date
- Dec 2009
- Posts
- 20
- Rep Power
- 0
are these al the options i can use instade of the "nl" option ?
output:
ja_JP
es_PE
en
ja_JP_JP
es_PA
sr_BA
mk
es_GT
ar_AE
no_NO
sq_AL
bg
ar_IQ
ar_YE
hu
pt_PT
el_CY
ar_QA
mk_MK
sv
de_CH
en_US
fi_FI
is
cs
en_MT
sl_SI
sk_SK
it
tr_TR
zh
th
ar_SA
no
en_GB
sr_CS
lt
ro
en_NZ
no_NO_NY
lt_LT
es_NI
nl
ga_IE
fr_BE
es_ES
ar_LB
ko
fr_CA
et_EE
ar_KW
sr_RS
es_US
es_MX
ar_SD
in_ID
ru
lv
es_UY
lv_LV
iw
pt_BR
ar_SY
hr
et
es_DO
fr_CH
hi_IN
es_VE
ar_BH
en_PH
ar_TN
fi
de_AT
es
nl_NL
es_EC
zh_TW
ar_JO
be
is_IS
es_CO
es_CR
es_CL
ar_EG
en_ZA
th_TH
el_GR
it_IT
ca
hu_HU
fr
en_IE
uk_UA
pl_PL
fr_LU
nl_BE
en_IN
ca_ES
ar_MA
es_BO
en_AU
sr
zh_SG
pt
uk
es_SV
ru_RU
ko_KR
vi
ar_DZ
vi_VN
sr_ME
sq
ar_LY
ar
zh_CN
be_BY
zh_HK
ja
iw_IL
bg_BG
in
mt_MT
es_PY
sl
fr_FR
cs_CZ
it_CH
ro_RO
es_PR
en_CA
de_DE
ga
de_LU
de
es_AR
sk
ms_MY
hr_HR
en_SG
da
mt
pl
ar_OM
tr
th_TH_TH
el
ms
sv_SE
da_DK
es_HN
- 05-08-2010, 03:56 PM #11
Member
- Join Date
- Dec 2009
- Posts
- 20
- Rep Power
- 0
thanks i think i got it
-
You are getting nl_NL, so you're good.
- 05-08-2010, 04:02 PM #13
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,424
- Blog Entries
- 7
- Rep Power
- 17
-
My latest take on this:
Java Code:import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class DutchDate { public static void main(String[] args) throws ParseException { String[] dutchDates = { "2 mei 2010", "7 mei 2010" }; Locale dutchLoc = new Locale("nl", "NL"); String nlFormatStr = "dd MMMM yyyy"; String usFormatStr = "yyyy-MM-dd"; SimpleDateFormat nlSdf = new SimpleDateFormat(nlFormatStr, dutchLoc); SimpleDateFormat usSdf = new SimpleDateFormat(usFormatStr, Locale.US); for (int i = 0; i < dutchDates.length; i++) { System.out.println("NL Date: " + dutchDates[i]); Date date = nlSdf.parse(dutchDates[i]); System.out.println("US Date: " + usSdf.format(date)); } } }
Similar Threads
-
Compare date input to database with current date
By hungleon88 in forum Advanced JavaReplies: 2Last Post: 11-25-2008, 08:10 AM -
Creating a Gregorian Calendar using a Date object gives date - 1
By prachi_goliwadekar in forum New To JavaReplies: 1Last Post: 05-08-2008, 08:32 PM -
Formatting time and date
By Java Tip in forum java.langReplies: 0Last Post: 04-17-2008, 07:35 PM -
Difference between current date and anothe date
By vijay balusamy in forum New To JavaReplies: 1Last Post: 04-16-2008, 04:15 PM -
Formatting the date
By yuchuang in forum New To JavaReplies: 5Last Post: 05-07-2007, 06:08 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks