Wednesday, July 25, 2007

Getting Java Date in another Timezone

Getting the date in another timezone is not quite as evident. But I did whip up a method to return the Date object if you provide your local Date and the timeZone id of where you want to find out what time it is there.

import java.util.*;

public class Timezone {

public static Date getDateInTimeZone(Date currentDate, String timeZoneId)
{
TimeZone tz = TimeZone.getTimeZone(timeZoneId);
Calendar mbCal = new GregorianCalendar(TimeZone.getTimeZone(timeZoneId));
mbCal.setTimeInMillis(currentDate.getTime());

Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, mbCal.get(Calendar.YEAR));
cal.set(Calendar.MONTH, mbCal.get(Calendar.MONTH));
cal.set(Calendar.DAY_OF_MONTH, mbCal.get(Calendar.DAY_OF_MONTH));
cal.set(Calendar.HOUR_OF_DAY, mbCal.get(Calendar.HOUR_OF_DAY));
cal.set(Calendar.MINUTE, mbCal.get(Calendar.MINUTE));
cal.set(Calendar.SECOND, mbCal.get(Calendar.SECOND));
cal.set(Calendar.MILLISECOND, mbCal.get(Calendar.MILLISECOND));

return cal.getTime();
}

public static void main(String[] args)
{
Date now = new Date();

System.out.println("Current Time="+now);
Calendar cal = Calendar.getInstance();
System.out.println("Current Timezone="+cal.getTimeZone().getDisplayName());

//Canada/Central
String timeZoneId = "Canada/Central";
System.out.println("Getting Time in the timezone="+timeZoneId);
System.out.println("Current Time there="+getDateInTimeZone(now,timeZoneId));
}

}

Tuesday, July 3, 2007

TOGAF (The Open Group Architecture Framework)

Well, I did receive Open Group's TOGAF 8 2006. Looks like a solid read with little fluff. Maybe a little like when I read the PMBOK but more interesting!

What is TOGAF? (The Open Group Architecture Framework)

TOGAF is an achitecture framework - The Open GROUP Architecture Framework. It enables you to design, evaluate, and build the right architecture for your organization.

The key to TOGAF is the Architecture Development Method (ADM) - a reliable, proven method for developing an IT enterprise architecture that meets the needs of your business.

It mentions that it can be used in conjunction with the Zachman Framework(of which I need to read up on), which has an excellent classification scheme, but lacks an openly available, well-defined methodology.

"The TOGAF ADM defines a recommended sequence for the various phases and steps involved in developing an architecture, but it cannot recommend a scope - this has to be determined by the organization itself, bearing in mind that the recommended sequence of development in the ADM process is an iterative one, with the depth and breadth of scope and deliverables increasing with each iteration." (p. 30, TOGAF 8)






ADM (Architecture Development Method)

Monday, July 2, 2007

The Leader In You


Finishing "The Leader In You" helps reinforce the ideas from the Carnegie Institute.

Written similarly to "How to Win Friends and Influence People" and "How to Stop Worrying and Start Living", it gives lessons through the stories and personal experiences of modern day(up to early 90s) leaders from business, politics and sports.

It was good but I would certainly recommend starting with the 2 books above before reading this one.
Human relationships are important and Carnegie will help you develop them.

A recap of the main principles in this book:
1. The first step toward success is identifying your own leadership strengths.
2.Communication is built on trusting relationships
3.Motivation can never be forced. People have to want to do a good job.
4. There's nothing more effective than rewarding than showing a genuine interest in other people.
5. Step outside yourself to discover what's important to someone else.
6. Nobody is more persuasive than a good listener.
7. Team players are the leaders of tomorrow.
8. Truly respecting others is the bedrock of motivation.
9. People work for money but go the extra mile for recognition, praise, and rewards.
10.Be quick to admit mistakes and slow to criticize. Above all, be constructive.
11.Set goals that are clear, challenging, and obtainable.
12. Leaders never lose their focus. They keep their eyes on the big picture.
13.Consistently high performance comes from a balance between work and pleasure.
14. Gain strength from the positive and don't be sapped by the negative.
15. Tame your worries and energize your life.
16. Never underestimate the power of enthusiasm.

Wednesday, June 27, 2007

SOA - A Planning and Implementation Guide For Business and Technology

I recently finished reading Service-Oriented Architecture - A Planning and Implementation Guide for Business and Technology, written by Eric A. Marks and Michael Bell.

I liked it because it frames SOA with more of a business perspective and how to approach SOA in general. We all know that SOA does not necessarily equal WS-*. Where often SOA books are throwing spec after spec at us.

This book provides advice on how to create an SOA model to enhance the 2 main goals of an SOA:


1. Improved Code Reuse

2. Quicker Time to Market for Software Projects


Chapter 3 - SOA Business Modelling provided an example of SOA Value Analysis with a matrix comparing the various areas of the Business Value Chain against SOA Value Drivers such as "Grow the Business","Reduce Costs", "Asset Reuse", "Business Agility","IT Flexibility","Time to Market","Business Processes","Process Visibility". This analysis can help identify "SOA hot spots" to help prioritize business processes.

I appreciated the "big picture" approach to the book. Where you started off considering things like SLAs (Service Level Agreements) and SOA Governance, without wondering how to patch different specs together. The diagrams were good, it looked like some custom notation however. A good bridging book between technology and business.

A pretty good book, glad I read it. The title makes alot of sense after reading the whole book :

SOA - A Planning And Implementation Guide For Business And Technology

Friday, June 15, 2007

JavaServer Faces!

I have been interested in an open source platform to launch a web site. I had heard the about jsf as a J2EE framework.

One is the lifecycle model better designed to protect the "model" of the MVC architecture.



The current available version is 1.2 which is available from Sun's Glassfish project. I was hoping the the Apache myfaces project would have a version 1.2 out but it seems they are still testing it.

Sun's version does not run on Tomcat, so I hope the MyFaces team can get 1.2 out soon. I have seen some indications that this can be checked out from cvs but not currently available as a release product.

My current set up is Tomcat,Eclipse,MyFaces,MySql along with the Sysdeo debugger.
Security for the app is set up using a Filter.
Basic templating done via Tiles.

I have some basic functionality up and running but I wanted to learn more about the JSF details before so I got a copy of "Core JavaServer Faces" by Geary,Horstmann. It was very good at filling in some gaps and revealing some other ideas I would like to incorporate in my J2EE apps.

It was good in describing the validation process, the JSF lifecycle(as diagrammed above), event handling, some of the Ajax code(Ajax4jsf).

When I get some more time I will revisit my application and incorporate some of this.

JSF is pretty neat!


Some good links:
http://myfaces.apache.org/
http://java.sun.com/javaee/javaserverfaces/
http://en.wikipedia.org/wiki/JavaServer_Faces
http://www.coreservlets.com/JSF-Tutorial/

Saturday, May 19, 2007

Reading RSS feeds with Java

If you were interested in incorporating RSS feeds into your java code you might want to have a look at Project Rome which is an open source java library for handling RSS feeds. Rome is currently in version 0.9 can be found at https://rome.dev.java.net/

I wrote a simple sample program which reads a given RSS feed and display some of the feed entries along with some attributes. It will also display the RSS version, as there are different versions of RSS. http://en.wikipedia.org/wiki/RSS_(file_format)

This simple program is the following:


import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndImageImpl;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
import com.sun.syndication.feed.synd.SyndContentImpl;


/*
* 2 Required Jar files
* rome-0.9.jar retrieved from http://rome.dev.java.net/
* jdom.jar retrieved from http://www.jdom.org/
*/

public class RSSReader
{

public static void iterateRSSFeed(String rssFeedUrl)
{
try
{
//open up a connection to the rss feed

URLConnection feedUrl = new URL(rssFeedUrl).openConnection();

//Create Feed Object
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));

System.out.println("Examining rss feed:"+rssFeedUrl+"\n");

System.out.println("Feed type="+feed.getFeedType());

//Iterate through object to get details
List list = feed.getEntries();

System.out.println("Feed image="+feed.getImage());
if (feed.getImage()!=null)
{
SyndImageImpl image = (SyndImageImpl)feed.getImage();
String imageInfo = "Image url:"+image.getUrl()+"\n";
System.out.println(imageInfo);
}
for (int i=0 ; i < list.size(); i++){

//display entry attributes
SyndEntry entry = (SyndEntry)list.get(i);
String display = "Entry:"+i;
display += "\ntitle:"+entry.getTitle();
display += "\nlink:"+entry.getLink();
display += "\nauthor:"+entry.getAuthor();
display += "\npublished:"+entry.getPublishedDate();
display += "\nupdated:"+entry.getUpdatedDate();
display += "\ndescription:"+entry.getDescription();

display += "\ncontent size:"+entry.getContents().size();
if (entry.getContents().size()==1)
{
SyndContentImpl imp = (SyndContentImpl)entry.getContents().get(0);
display += "\ncontent value:"+imp.getValue();
}
display += "\n";
System.out.println(display);

}

}
catch(Exception e)
{
e.printStackTrace();
}

}


public static void main(String[] args) {

//James Gosling's blog
String rssFeedUrl = "http://blogs.sun.com/jag/feed/entries/rss";

//Mark Cuban's blog
//rssFeedUrl = "http://www.blogmaverick.com/rss.xml";

//rssFeedUrl = "http://techinitiatives.blogspot.com/feeds/posts/default";

//RSS 2.0
//rssFeedUrl = "http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c";

iterateRSSFeed(rssFeedUrl);


}
}

Wednesday, May 2, 2007

Developing Knowledge-Based Client Relationships

I just finished Ross Dawson's "Developing Knowledge-Based Client Relationships". I found it useful in understanding more of the business side of consulting and client relationships.

The book provides a couple of interesting definitions. "Information is anything that can be digitized, while knowledge is the capacity to act effectively, an attribute unique to people."p.96

Strategy in these types of client relationships is to evolve where the vendor and client integrate/collaborate at a high level to create higher levels of value creation.

A vendor should strive to avoid black box/commodity work and strive for the higher level knowledge based/collaborative solutions.

This was a good book for illuminating how to deal with clients strategically. Similar to "The Trusted Advisor". This was a good read before I dive back into more technical reads. :-)