The Artima Developer Community
Sponsored Link

Java Buzz Forum
The Java Developers Almanac 1.4

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ben Hosking

Posts: 208
Nickname: hoskinator
Registered: Apr, 2006

Ben Hosking is Java Developer with about 5 years experience and interest in OO
The Java Developers Almanac 1.4 Posted: Jun 1, 2006 2:38 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Ben Hosking.
Original Post: The Java Developers Almanac 1.4
Feed Title: A Funny Java Flavoured Look at the World
Feed URL: http://businesslogs.com/WebLog/RSS.xml
Feed Description: The blog looks at using Java and programming in general as it pops up in life as a Java programmer. It will have links to interesting Java articles and resources. It will also have a lot of SCJP Java 1.5 information and links as I am currently studying
Latest Java Buzz Posts
Latest Java Buzz Posts by Ben Hosking
Latest Posts From A Funny Java Flavoured Look at the World

Advertisement

I find this site today, well I found it because it was one of the Java Series books that Sun promotes but this one had a website, which means I can see the goodies for free.

 

it is similar in some ways to Java Tips, which I have blogged about http://hoskinator.blogspot.com/2006/04/java-tips.html

except that this site is purely just code examples where as Java tips does have explanations as well.

 

The code examples are split up into packages but it does have a useful search facility where you can search for the code example you are interested in. The obvious down fall is the code examples are for 1.4 and not 1.5 and it hasn't been updated for quite a while. 

 

It gives you just a short concise example of the code you are interested in, I always like seeing an example and then changing and modifying it to do want I want, it always seems a good starting point e.g. you have something that works and then you change

 

If anyone has any other code example site's like this I would like to hear about them and mention them in the comments if you would be so kind.

 

it has some good sections on java.sql, java.text and java.reflect and lots more

 

a few examples of the type of things featured on the site

 






 

below is the entry for Formatting a Date using a Custom Format


e316. Formatting the Time Using a Custom Format

A pattern of special characters is used to specify the format of the time. This example demonstrates some of the characters. For a complete listing, see the javadoc documentation for the SimpleDateFormat class.

Note: This example formats dates using the default locale (which, in the author's case, is Locale.ENGLISH). If the example is run in a different locale, the text (e.g., month names) will not be the same.

    Format formatter;

// The hour (1-12)
formatter = new SimpleDateFormat("h"); // 8
formatter = new SimpleDateFormat("hh"); // 08

// The hour (0-23)
formatter = new SimpleDateFormat("H"); // 8
formatter = new SimpleDateFormat("HH"); // 08

// The minutes
formatter = new SimpleDateFormat("m"); // 7
formatter = new SimpleDateFormat("mm"); // 07

// The seconds
formatter = new SimpleDateFormat("s"); // 3
formatter = new SimpleDateFormat("ss"); // 03

// The am/pm marker
formatter = new SimpleDateFormat("a"); // AM

// The time zone
formatter = new SimpleDateFormat("z"); // PST
formatter = new SimpleDateFormat("zzzz"); // Pacific Standard Time
formatter = new SimpleDateFormat("Z"); // -0800

// Get today's date
Date date = new Date();

// Some examples
formatter = new SimpleDateFormat("hh:mm:ss a");
String s = formatter.format(date);
// 01:12:53 AM

formatter = new SimpleDateFormat("HH.mm.ss");
s = formatter.format(date);
// 14.36.33

Read: The Java Developers Almanac 1.4

Topic: Ajax Tutorial - Top 20 Previous Topic   Next Topic Topic: OSFlash

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use