•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the HTML and CSS section within the Web Development category of DaniWeb, a massive community of 397,813 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,573 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 623 | Replies: 1
![]() |
•
•
Join Date: Mar 2007
Posts: 83
Reputation:
Rep Power: 0
Solved Threads: 2
You say in the title js... if you mean Javascript, then you should post in the Javascritp lists, you'll get better results... If it is a typo and you meant JSP, then I will see what I can do...
However, the priciple is basically the same...
You can build a new date object from the ISO standard string format then use that date object with a date format object to output the date anyway you like...
Do a quick search for SimpleDateFormat on google and you will find pretty much everything you need...
Sorry, but there is too much to detail here...
If it is Javascript you are looking at, you can certainly do it similarly...
If the date is coming from a database, see what you can do for the formating prior to extracting the date, this is DB dependant so I can't give you specifics there, but for example, I use PostgreSQL 8.2 in many of my applications and I usually store timestamp with timezone... Then I can select it as a date which outputs as 4/1/2007 or similar...
If the dates are instrings you can always build a parser routine in js or java to do the work if you like...
String sMyDate = "Sun Apr 1 00:00:00 UTC+200 2007";
String[] aDateParts = sMyDate.split(" ");//the empty space
HashMap<String, Integer> hm = new HashMap(12);
hm.put("Apr", 4); // just a simple mapping
String sDisplayDate = hm.get(aDateParts[1]) + "/" + aDateParts[2] + "/" + aDateParts[5] + " " + aDateParts[3];
That is about it if you are doing string manipulation, which in some cases is faster than creating a date from a string, reformating it using date formatter then outputting it as a date again...
If you have any questions feel free to contact me... The string manipulation method will work in Javascript too, with almost the same code...
However, the priciple is basically the same...
You can build a new date object from the ISO standard string format then use that date object with a date format object to output the date anyway you like...
Do a quick search for SimpleDateFormat on google and you will find pretty much everything you need...
Sorry, but there is too much to detail here...
If it is Javascript you are looking at, you can certainly do it similarly...
If the date is coming from a database, see what you can do for the formating prior to extracting the date, this is DB dependant so I can't give you specifics there, but for example, I use PostgreSQL 8.2 in many of my applications and I usually store timestamp with timezone... Then I can select it as a date which outputs as 4/1/2007 or similar...
If the dates are instrings you can always build a parser routine in js or java to do the work if you like...
String sMyDate = "Sun Apr 1 00:00:00 UTC+200 2007";
String[] aDateParts = sMyDate.split(" ");//the empty space
HashMap<String, Integer> hm = new HashMap(12);
hm.put("Apr", 4); // just a simple mapping
String sDisplayDate = hm.get(aDateParts[1]) + "/" + aDateParts[2] + "/" + aDateParts[5] + " " + aDateParts[3];
That is about it if you are doing string manipulation, which in some cases is faster than creating a date from a string, reformating it using date formatter then outputting it as a date again...
If you have any questions feel free to contact me... The string manipulation method will work in Javascript too, with almost the same code...
Last edited by rgtaylor : Apr 6th, 2007 at 2:54 am. Reason: typo
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb HTML and CSS Marketplace
- need hlep with finding a topic for my final year project (Computer Science and Software Design)
- Forum lurkers, introduce yourself ... !! (Community Introductions)
- Need Help on showInputDialog (Java)
- finding area of something (Computer Science and Software Design)
- something wrong with IE6 (Web Browsers)
Other Threads in the HTML and CSS Forum
- Previous Thread: newbie??? Including text files in html
- Next Thread: getting layermovement in netscape


Linear Mode