<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jayway Team Blog &#187; User Experience</title>
	<atom:link href="http://blog.jayway.com/category/user-experience/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jayway.com</link>
	<description>Sharing Experience</description>
	<lastBuildDate>Sat, 11 Feb 2012 10:33:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Getting ShowOff source code high-lighting for Clojure</title>
		<link>http://blog.jayway.com/2011/09/10/getting-showoff-source-code-high-lighting-for-clojure/</link>
		<comments>http://blog.jayway.com/2011/09/10/getting-showoff-source-code-high-lighting-for-clojure/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 22:50:29 +0000</pubDate>
		<dc:creator>Ulrik Sandberg</dc:creator>
				<category><![CDATA[Dynamic languages]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[clojure source highlight]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=9274</guid>
		<description><![CDATA[ShowOff is a presentation software where you create your slides by writing simple text files containing markdown formatting. Styling is done using CSS. The slides are served by a web server and can be displayed in a web browser. With a simple command, a presentation can be deployed on Heroku for everyone to see. ShowOff [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://github.com/schacon/showoff">ShowOff</a> is a presentation software where you create your slides by writing simple text files containing <a href="http://daringfireball.net/projects/markdown/">markdown</a> formatting. Styling is done using CSS. The slides are served by a web server and can be displayed in a web browser. With a simple command, a presentation can be deployed on <a href="http://www.heroku.com/">Heroku</a> for everyone to see. ShowOff can even execute code and show the result (currently that's possible for Ruby and JavaScript).</p>
<p>ShowOff is great if you are fed up with the bloated presentation applications that make a mess of your source code. Text files means that presentations can be properly version controlled. It's easy to re-arrange slides and sections. ShowOff uses <a href="http://shjs.sourceforge.net/">SHJS</a> to highlight code blocks. It supports many languages, but currently not <a href="http://clojure.org/">Clojure</a>. Searching around for a while revealed <a href="https://gist.github.com/265810/78857041d922c21488415a9b7ec0300aece47009">a Gist of SHJS styling code</a> that I wanted to try out:</p>
<pre>
# Clojure syntax highlighting for GNU source-highlight
# rocks with SHJS
comment start ";"
include "number.lang"
vardef SPECIALCHAR = '\\.'
environment string delim "\"" "\"" begin
  specialchar = $SPECIALCHAR
end
type = "int|byte|boolean|char|long|float|double|short|void"
vardef FUNCTION = '\(([[:alpha:]]|_)[[:word:]]*(?=[[:blank:]]*)'
function = $FUNCTION
include "symbols.lang"
</pre>
<p>This is what I did on my MacOSX Snow Leopard to get ShowOff to high-light Clojure source code:</p>
<p>1. Install some pre-requisites. I use <a href="http://mxcl.github.com/homebrew/">HomeBrew</a>, but you can use MacPorts or whatever package manager you prefer.</p>
<pre>
gem install showoff</code>
brew install yuicompressor
brew install source-highlight
brew install unix2dos
</pre>
<p>2. Download the <a href="http://sourceforge.net/projects/shjs/files/shjs/0.6/shjs-0.6-src.zip/download">shjs source distro</a>.</p>
<p>3. Unzip shjs-0.6-src.zip somewhere which we will call SHJS_HOME</p>
<p>4. cd SHJS_HOME</p>
<p>5. touch source-highlight-lang/clojure.lang</p>
<p>6. Edit source-highlight-lang/clojure.lang and paste <a href="https://gist.github.com/265810/78857041d922c21488415a9b7ec0300aece47009">this Clojure source code high-lighting spec</a> (that's the same as displayed above).</p>
<p>7. My Perl installation needed a recursive descent parser, so I did this: <code><br />
cpan install Parse::RecDescent</code></p>
<p>8. make</p>
<p>9. I then copied the resulting minified JavaScript file to where my ShowOff gem keeps the language style files. I use the <a href="http://beginrescueend.com/">RVM</a> Ruby manager, so this is where I needed it:</p>
<pre>
cp lang/sh_clojure.min.js ~/.rvm/gems/ruby-1.9.2-p290/gems/showoff-0.4.2/public/js/sh_lang/
</pre>
<p>Should you discover that you need some more tools installed, you can clean up with <code>make maintainer-clean</code>. After you installed whatever you were missing, run <code>make</code> again.</p>
<h2>Testing Clojure high-lighting</h2>
<p>In order to test this, we will create a simple presentation called "mypres":</p>
<pre>
showoff init mypres
</pre>
<p>This creates a new directory <code>mypres</code>. We go to that directory and look around:</p>
<pre>
.
├── one
│   └── 01_slide.md
└── showoff.json
</pre>
<p>OK, so we have now the skeleton of a presentation, containing a section folder named <code>one</code> and a set of slides in the <code>01_slide.md</code> file. Looking closer at that file, we see this:</p>
<pre>
!SLIDE
# My Presentation #

!SLIDE bullets incremental
# Bullet Points #

* first point
* second point
* third point
</pre>
<p>We will now add to this file a slide definition with some Clojure source code, formatted as a code block by indenting it. Note that we have preceded the code with <code>@@@ clojure</code>, in order to tell ShowOff what language we want to format the block as:</p>
<pre>
!SLIDE encode-symbol
# Huffman encoding #

	@@@ clojure
	(defn encode
	  "takes as arguments a message and a tree
	 and produces the list of bits that gives
	 the encoded message"
	[[first & rest :as message] tree]
	  (when (seq message)
	    (concat (encode-symbol first tree)
	            (encode rest tree))))
</pre>
<p>We serve the presentation:</p>
<pre>
$ showoff serve
</pre>
<p>Finally we can watch the presentation by browsing to http://localhost:9090</p>
<div id="attachment_9288" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/09/ShowOff-with-Clojure1.png" rel="lightbox"><img src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/09/ShowOff-with-Clojure1-300x187.png" alt="" title="ShowOff with Clojure" width="300" height="187" class="size-medium wp-image-9288" /></a><p class="wp-caption-text">ShowOff source code high-lighting for Clojure</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2011/09/10/getting-showoff-source-code-high-lighting-for-clojure/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How mail sync killed the battery on my WP7</title>
		<link>http://blog.jayway.com/2011/08/24/how-mail-sync-killed-the-battery-on-my-wp7/</link>
		<comments>http://blog.jayway.com/2011/08/24/how-mail-sync-killed-the-battery-on-my-wp7/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 21:57:59 +0000</pubDate>
		<dc:creator>Håkan Reis</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[battery]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[mango]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[wp7]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/2011/08/24/how-mail-sync-killed-the-battery-on-my-wp7/</guid>
		<description><![CDATA[The last couple of days the battery life on my Windows Phone Mango has been catastrophic. I wasn’t able to last more than 3-4 hours, tops. Then the battery saver icon appeared (battery with a little heart over it) and gave me a couple extra hours, it really is a saver. The only thing that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/08/no_battery.png" rel="lightbox"><img style="background-image: none; border-right-width: 0px; margin: 0px 10px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="no_battery" border="0" alt="no_battery" align="left" src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/08/no_battery_thumb.png" width="99" height="99" /></a>The last couple of days the battery life on my Windows Phone Mango has been catastrophic. I wasn’t able to last more than 3-4 hours, tops. Then the battery saver icon appeared (battery with a little heart over it) and gave me a couple extra hours, it really is a saver. The only thing that I could think of, that I had changed, was that shuffling the images used as background in pictures hub. So I began to restart, charge, changed settings, disconnected Wi-Fi. I tried all kind of tricks that affects battery life. No luck.</p>
<p>Then I thought that maybe I should stop syncing mail so often and se what effect that would have. When I tried to change my settings I saw how it was syncing mail, lots of mail in my account. It never seem to stop and suddenly it hit me:</p>
<p>I might have set it to sync my <em>All mails</em> folder in my Google mail, and that isn’t a good thing. If it tries to sync all then there is 56 472 conversations dragging around in my Google account (I haven't thrown away any mail, except for spam mail and mailing list, the last 8 years). And even if I narrow this down to the last 7 days it’s a lot of mail to sync in the background. No wonder it was draining the battery. An I was right.</p>
<p>Actually here are a few areas that can improve in the user interface. Doing all this syncing was not good for the performance of the mail application either. I even had trouble to stop the sync of the <em>All mails</em> folder. And while the account was syncing I wasn’t able to remove it or change any settings on it. </p>
<p>In the end I figured that the easiest way to get rid of it all was to just go into flight mode, remove the account and then add it again (after going out of flight mode). This time I made sure it’s just the inbox that is synced. And now all is back to normal again or even better.</p>
<p>So be careful with what you sync or it may really kill the battery on your device.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2011/08/24/how-mail-sync-killed-the-battery-on-my-wp7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Send growl notifications from Java using a script engine and AppleScript</title>
		<link>http://blog.jayway.com/2011/04/12/send-growl-notifications-on-os-x-using-a-java-6-script-engine-and-applescript/</link>
		<comments>http://blog.jayway.com/2011/04/12/send-growl-notifications-on-os-x-using-a-java-6-script-engine-and-applescript/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 11:54:02 +0000</pubDate>
		<dc:creator>Tobias Södergren</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[growl]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[script engine]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=7939</guid>
		<description><![CDATA[Growl is a notification system for Mac OS X and "Growl lets Mac OS X applications unintrusively tell you when things happen". The about page shows an example of what Growl looks like. If you have written a Java application and want to enable Growl notifications for it, you previously had the possibility to use [...]]]></description>
			<content:encoded><![CDATA[<p>Growl is a notification system for Mac OS X and "Growl lets Mac OS X applications unintrusively tell you when things happen". The <a href="http://growl.info/about.php">about page</a> shows an example of what Growl looks like. </p>
<p/>
If you have written a Java application and want to enable Growl notifications for it, you previously had the possibility to use cocoa Java bindings for Growl but they have been deprecated and are no longer supported. However, there is an <a href="http://growl.info/documentation/applescript-support.php">AppleScript API</a> that together with the AppleScript script engine can give access to Growl from Java. If you use Java 6 that is.</p>
<h2>The example</h2>
<p>This example code uses the Growl class, defined below, which uses the Growl AppleScript API and Java AppleScript script engine in OS X:</p>
<pre class="brush:java; gutter:false">
public class GrowlDemo {
    public static void main(String... args) {
        // System and boss messages will be enabled by default, spam must be configured in growl settings
        Growl growl = new Growl("Growl Demo",
                new String[]{"system", "boss", "spam"},
                new String[]{"system", "boss"});
        growl.init();
        growl.registerApplication();
        growl.notify("system", "System message", "This seem to be working");
        growl.notify("boss", "From: Big brother", "Get back to work!");
        growl.notify("spam", "Get a diploma", "By going to university");
    }
}
</pre>
<p>The output will look something like:<br />
<div id="attachment_7957" class="wp-caption alignnone" style="width: 322px"><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/04/growl-notification-example.png" rel="lightbox"><img src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/04/growl-notification-example.png" alt="Example of Growl notification with demo code" title="growl-notification-example" width="312" height="150" class="size-full wp-image-7957" /></a><p class="wp-caption-text">Demo code output</p></div></p>
<p/>
Now on to the Growl AppleScript API implementation.</p>
<h2>The Growl code</h2>
<p>In order to use the AppleScript engine, an engine and a context has to be retrieved. Here's an example:</p>
<p/>
<pre class="brush:java; gutter:false">
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
ScriptEngine appleScriptEngine = scriptEngineManager.getEngineByName("AppleScript");
Script script = "&lt;AppleScript syntax goes here&gt;";
appleScriptEngine.eval(script, appleScriptEngine.getContext());
</pre>
<p/>
The rest of the code is just building the AppleScript API syntax for Growl:</p>
<p/>
<pre class="brush:java; gutter:false">
package com.jayway.growl;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 * Notify with Growl using AppleScript and Java Script engine.
 *
 * @author Tobias Södergren, Jayway
 */
public class Growl {
    private static final String GROWL_APPLICATION = "GrowlHelperApp";
    private final String applicationName;
    private String[] availableNotifications;
    private String[] enabledNotifications;
    private ScriptEngine appleScriptEngine;

    public Growl(String applicationName, String[] availableNotifications, String[] enabledNotifications) {
        this.applicationName = applicationName;
        this.availableNotifications = availableNotifications;
        this.enabledNotifications = enabledNotifications;
    }

    public void init() {
        ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
        appleScriptEngine = scriptEngineManager.getEngineByName("AppleScript");
        if (appleScriptEngine == null) {
            throw new RuntimeException("No AppleScriptEngine available");
        }

        if (!isGrowlEnabled()) {
            throw new RuntimeException("No Growl process was found.");
        }
    }

    public void registerApplication() {
        String script = script().add("tell application ")
                .quote(GROWL_APPLICATION)
                .nextRow("set the availableList to ")
                .array(availableNotifications)
                .nextRow("set the enabledList to ")
                .array(enabledNotifications)
                .nextRow("register as application ")
                .quote(applicationName)
                .add(" all notifications availableList default notifications enabledList")
                .nextRow("end tell").get();
        executeScript(script);
    }

    public void notify(String notificationName, String title, String message) {
        String script = script().add("tell application ")
                .quote(GROWL_APPLICATION)
                .nextRow("notify with name ").quote(notificationName)
                .add(" title ").quote(title)
                .add(" description ").quote(message)
                .add(" application name ").quote(applicationName)
                .nextRow("end tell").get();
        executeScript(script);
    }

    private boolean isGrowlEnabled() {
        String script = script().add("tell application ")
                .quote("System Events")
                .nextRow("return count of (every process whose name is ")
                .quote(GROWL_APPLICATION).add(") > 0")
                .nextRow("end tell")
                .get();
        long count = executeScript(script, 0L);
        return count > 0;
    }

    private &lt;T&gt; T executeScript(String script, T defaultValue) {
        try {
            return (T) appleScriptEngine.eval(script, appleScriptEngine.getContext());
        } catch (ScriptException e) {
            return defaultValue;
        }
    }

    private void executeScript(String script) {
        try {
            appleScriptEngine.eval(script, appleScriptEngine.getContext());
        } catch (ScriptException e) {
            // log.error("Problem executing script, e);
        }
    }

    private ScriptBuilder script() {
        return new ScriptBuilder();
    }

    private class ScriptBuilder {
        StringBuilder builder = new StringBuilder();

        public ScriptBuilder add(String text) {
            builder.append(text);
            return this;
        }

        public ScriptBuilder quote(String text) {
            builder.append("\"");
            builder.append(text);
            builder.append("\"");
            return this;
        }

        public ScriptBuilder nextRow(String text) {
            builder.append("\n");
            builder.append(text);
            return this;
        }

        public String get() {
            return builder.toString();
        }

        public ScriptBuilder array(String[] array) {
            builder.append("{");
            for (int i = 0; i < array.length; i++) {
                if (i > 0) {
                    builder.append(", ");
                }
                builder.append("\"");
                builder.append(array[i]);
                builder.append("\"");
            }

            builder.append("}");
            return this;
        }
    }
}
</pre>
<p>That's it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2011/04/12/send-growl-notifications-on-os-x-using-a-java-6-script-engine-and-applescript/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Design/performance &#8211; WP7 in blend and code</title>
		<link>http://blog.jayway.com/2011/03/31/designperformance-wp7-in-blend-and-code/</link>
		<comments>http://blog.jayway.com/2011/03/31/designperformance-wp7-in-blend-and-code/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 08:47:32 +0000</pubDate>
		<dc:creator>Håkan Reis</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[techdays]]></category>
		<category><![CDATA[user experience]]></category>
		<category><![CDATA[ux]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[wp7dev]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=7809</guid>
		<description><![CDATA[We (Andreas Hammar and I) are just returning from Tech-Days 2011, we delivered a session on developing applications for Windows Phone 7 in Blend and code. While we were preparing for this session something stuck in our minds - when it comes to mobile applications the top priority is in design and performance. Design and [...]]]></description>
			<content:encoded><![CDATA[<p>We (<a href="http://blog.jayway.com/author/andreashammar/" target="_blank">Andreas Hammar</a> and <a href="http://blog.jayway.com/author/hakanreis/" target="_blank">I</a>) are just returning from Tech-Days 2011, we delivered a session on developing applications for Windows Phone 7 in Blend and code. While we were preparing for this session something stuck in our minds - when it comes to mobile applications the top priority is in design and performance.</p>
<blockquote><p><strong>Design and performance</strong> over architecture and frameworks</p></blockquote>
<p>We have to focus our attention on the user experience, how the application is perceived and not what technology is used or how the application is built. The important thing is that the application is well designed and that it responds to the user. SO to be a WP7 developer there are two things you really have to study, and study hard:</p>
<blockquote><p><strong>Design<br />
Performance</strong></p></blockquote>
<p>We're not suggesting that you throw out all the knowledge around architecture and framework. But, if it impacts design and performance you should think twice about why. Also, as Johan Lindfors said in his session – “<strong>stop building frameworks! </strong>Start building applications”</p>
<h2>Slides and samples</h2>
<p>Anyway, to sum this up we share the slides on slideshare as well as provide the code and slides as files below.</p>
<div id="__ss_7458800" style="width: 425px;"><strong style="display: block; margin: 12px 0 4px;"><a title="Windows Phone 7 in Blend and Code" href="http://www.slideshare.net/haqwin/windows-phone-7-in-blend-and-code">Windows Phone 7 in Blend and Code</a></strong><object id="__sse7458800" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=windowsphone7inblendandcode-110331033737-phpapp01&amp;stripped_title=windows-phone-7-in-blend-and-code&amp;userName=haqwin" /><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><embed type="application/x-shockwave-flash" width="425" height="355" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=windowsphone7inblendandcode-110331033737-phpapp01&amp;stripped_title=windows-phone-7-in-blend-and-code&amp;userName=haqwin" name="__sse7458800" allowscriptaccess="always" allowfullscreen="true"></embed></object></div>
<p>&nbsp;</p>
<blockquote><p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/demo.zip" target="_self">Windows Phone 7 in blend and code – code</a><br />
<a href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/WindowsPhone7InBlendAndCode.pdf" target="_self">Windows Phone 7 in blend and code - slides</a></p></blockquote>
<h2>Resources</h2>
<p>Following is a collection of useful links to get started with real development - just promise you don’t build another framework.</p>
<ul>
<li><a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/03/18/windows-phone-7-series-ui-design-amp-interaction-guide.aspx" target="_blank">The UI and interaction guideline for Windows Phone 7</a></li>
<li><a href="http://www.jeff.wilcox.name/2011/03/metro-design-guide-v1/" target="_blank">Jeff Wilcox designer guideline for developers</a></li>
<li><a href="http://blogs.msdn.com/b/ptorr/archive/2010/10/30/that-memory-thing-i-promised-you.aspx" target="_blank">Peter Torr’s memory profiler</a></li>
<li><a href="http://silverlight.codeplex.com/" target="_blank">Silverlight Toolkit</a></li>
<li><a href="http://blogs.msdn.com/b/delay/archive/2010/09/02/keep-a-low-profile-lowprofileimageloader-helps-the-windows-phone-7-ui-thread-stay-responsive-by-loading-images-in-the-background.aspx" target="_blank">LowProfileImageLoader</a> by David Anson</li>
<li><a href="http://www.scottlogic.co.uk/blog/colin/2011/01/windows-phone-7-deferredloadcontentcontrol/" target="_blank">DeferredLoadContentControl</a> by Colin Eberhardt</li>
<li>Peter Torr’s <a href="http://blogs.msdn.com/b/ptorr/archive/2010/10/12/procrastination-ftw-lazylistbox-should-improve-your-scrolling-performance-and-responsiveness.aspx" target="_blank">LazyListBox</a></li>
<li>Gif decoder as part of the <a href="http://imagetools.codeplex.com/" target="_blank">ImageTools for silverlight</a></li>
</ul>
<p>Be creative! // <a href="http://blog.jayway.com/author/andreashammar/" target="_blank">Andreas Hammar</a> &amp; <a title="about me" href="http://blog.jayway.com/author/hakanreis/" target="_blank">Håkan Reis</a></p>
<p><script src="http://b.scorecardresearch.com/beacon.js?c1=7&amp;c2=7400849&amp;c3=1&amp;c4=&amp;c5=&amp;c6="></script> <script src="http://b.scorecardresearch.com/beacon.js?c1=7&amp;c2=7400849&amp;c3=1&amp;c4=&amp;c5=&amp;c6="></script></p>
<p><script src="http://b.scorecardresearch.com/beacon.js?c1=7&amp;c2=7400849&amp;c3=1&amp;c4=&amp;c5=&amp;c6="></script><script src="http://b.scorecardresearch.com/beacon.js?c1=7&amp;c2=7400849&amp;c3=1&amp;c4=&amp;c5=&amp;c6="></script></p>
<p><script src="http://b.scorecardresearch.com/beacon.js?c1=7&amp;c2=7400849&amp;c3=1&amp;c4=&amp;c5=&amp;c6="></script><br />
<script src="http://b.scorecardresearch.com/beacon.js?c1=7&amp;c2=7400849&amp;c3=1&amp;c4=&amp;c5=&amp;c6="></script></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2011/03/31/designperformance-wp7-in-blend-and-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Forget about touch control!</title>
		<link>http://blog.jayway.com/2011/03/11/forget-about-touch-control/</link>
		<comments>http://blog.jayway.com/2011/03/11/forget-about-touch-control/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 13:31:25 +0000</pubDate>
		<dc:creator>Håkan Reis</dc:creator>
				<category><![CDATA[User Experience]]></category>
		<category><![CDATA[nokia]]></category>
		<category><![CDATA[rant]]></category>
		<category><![CDATA[samsung]]></category>
		<category><![CDATA[touch]]></category>
		<category><![CDATA[ux]]></category>
		<category><![CDATA[windows phone 7]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=7529</guid>
		<description><![CDATA[Touch is great thing, suddenly you can touch, tap, double tap, flick, pinch and stretch to manipulate virtual object. It really revamped the whole mobile business mainly with the release of the iPhone and the capacitive touch screens, used in most smartphones today. But also in the stuff using infrared matrix screens like the Neonode [...]]]></description>
			<content:encoded><![CDATA[<p>Touch is great thing, suddenly you can touch, tap, double tap, flick, pinch and stretch to manipulate virtual object. It really revamped the whole mobile business mainly with the release of the iPhone and the capacitive touch screens, used in most smartphones today. But also in the stuff using infrared matrix screens like the Neonode back in 2004 that had quite good gesture control but never took off.</p>
<p>But let the touch stay there in a virtual interface on the screen. We all know and love what we got there. But if you have a real physical nice button DON'T MAKE IT A TOUCH BUTTON. Physical buttons should stay physical, a touch button is actually just an approximation to the real thing. That was cool in the 80-ties. If you really, really, can't help yourself, at least keep them safe from accidental touch. I’ll give you some example from bad to worse …</p>
<p><a rel="lightbox" href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/WP_000010.jpg"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="WP_000010" src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/WP_000010_thumb.jpg" border="0" alt="WP_000010" width="154" height="204" /></a><br />
<em>The new XBOX 360</em></p>
<p>This device uses touch to open the tray door and for the on/off switch. Its not a big problem here, the XBOX isn’t moved around much and mostly you don’t touch it by accident. But sometimes, you need to move it. I have it hidden away and I was opening the doors and accidently opened the tray. The sound it made when it hit the wall wasn’t too pleasing but it survived.</p>
<p><a rel="lightbox" href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/WP_000127.jpg"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="WP_000127" src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/WP_000127_thumb.jpg" border="0" alt="WP_000127" width="204" height="154" /></a><br />
<em>My stove</em></p>
<p>This one is even more annoying. The buttons are placed close to where you normally would have physical buttons and it works well when you and navigate them. But there are a few occasions… If you accidentally cover them they start to do all sorts of crazy stuff until the stove, as a security feature, shut down totally. Also, when you have a big handle cover one panel it reacts,  suddenly you wonder what happen until you realize that you have turned off the heat.</p>
<p><a rel="lightbox" href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/photo-1.jpg"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="photo (1)" src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/photo-1_thumb.jpg" border="0" alt="photo (1)" width="204" height="154" /></a><br />
<em>My Samsung Omnia 7</em></p>
<p>This is by far one of the worst examples of touch buttons. It doesn’t provide any functionality other than looks (and I think you could have gotten the same look with real buttons, with the right materials). It is constantly in the way and trying to play a game is almost impossible as you have your whole thumb over the buttons. I nearly thrown this out the window…</p>
<h2>Are there any good versions?</h2>
<p>Well I think my old Bang&amp;Olufsen sound system from 1991 is ok, touch button is not a killer feature but adds coolness to this piece of machinery, not that I know what I’m going to use my CD-player or cassette deck for anymore <img class="wlEmoticon wlEmoticon-smile" style="border-style: none;" src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/wlEmoticon-smile.png" alt="Smile" /></p>
<p><a rel="lightbox" href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/WP_000008.jpg"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="WP_000008" src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/WP_000008_thumb.jpg" border="0" alt="WP_000008" width="204" height="154" /></a> <a rel="lightbox" href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/WP_000012.jpg"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="WP_000012" src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/WP_000012_thumb.jpg" border="0" alt="WP_000012" width="204" height="154" /></a><br />
<em>B&amp;O 4500 with the military grade remote - could easily take out any enemy</em></p>
<p>It’s also good in that it’s easy to keep clean, it does not produce any false taps or clicks (being placed on a wall and all). It’s only a design thing using touch here but it doesn’t make it worse, besides, it’s the massive one pound remote that is used to control this…</p>
<p>The stove, again, is actually also a good contender for touch buttons:</p>
<p><a rel="lightbox" href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/WP_000014.jpg"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="WP_000014" src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/WP_000014_thumb.jpg" border="0" alt="WP_000014" width="204" height="154" /></a><em><br />
Easy to clean</em></p>
<p>There is one really good reasons for using touch here and it compensates for the problems - it’s so easy to keep clean.</p>
<h2>So, a final plea!</h2>
<p>I first thought of this when I moved in and started the fight with my stove. Then there was mockups leaks of the Windows Phone 7 HTC models. After that, I got my Samsung Omnia 7 in October. I think this is THE most annoying “feature” of the Omnia. But now there is a bigger threat - the mockups that Nokia made for the new Windows Phone 7 models. Look here:</p>
<p><a rel="lightbox" href="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/ConceptNokiaWindowsPhones1.jpg"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="ConceptNokiaWindowsPhones1" src="http://blog.jayway.com/wordpress/wp-content/uploads/2011/03/ConceptNokiaWindowsPhones1_thumb.jpg" border="0" alt="ConceptNokiaWindowsPhones1" width="204" height="154" /></a></p>
<p>This is really scary, touch buttons, and even worse than the Samsung Omnia, the home button is also touch here. This is going to drive at least me crazy. So please forget about touch here!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2011/03/11/forget-about-touch-control/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WP7: Background execution &#8211; really?</title>
		<link>http://blog.jayway.com/2011/01/11/wp7-background-execution-really/</link>
		<comments>http://blog.jayway.com/2011/01/11/wp7-background-execution-really/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 07:59:00 +0000</pubDate>
		<dc:creator>Håkan Reis</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[windows phone 7]]></category>
		<category><![CDATA[wp7dev]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=7018</guid>
		<description><![CDATA[One of the major complaints on the Windows Phone 7 platform is that you can’t run third party applications in the background. I had the same complaint on iPhone for a long time but over the time I have started to think about the problem and I’m not sure background operation for third party application [...]]]></description>
			<content:encoded><![CDATA[<p>One of the major complaints on the Windows Phone 7 platform is that you can’t run third party applications in the background. I had the same complaint on iPhone for a long time but over the time I have started to think about the problem and I’m not sure background operation for third party application is the only way to solve all the problems.</p>
<p>Let’s look at two scenarios that I think are the most common for background operation: Music player services like Spotify or Last.fm and GPS related applications like the RunKeeper GPS tracker. In these two main scenarios I think a richer and more service oriented API within the phone could take care of the problem instead of background execution.</p>
<h2>Lets focus on the audio service first</h2>
<p>No doubt that you need it to continue playing music while you work on other stuff. That’s not what I suggest but instead I want you to think of the application that is native in the phone, the Zune media player. Why would I want to create a new player over and over again? Wouldn’t it be better to integrate with the current? If the API was richer, in the Spotify case it would be possible to:</p>
<ul>
<li>Plug in the codec + DRM that’s used in Spotify </li>
<li>Create and use <em>playlists</em> from either streamed material or locally stored material – or both </li>
<li>Update the background image and access to all the data that is visible in the player </li>
<li>Add the playlists as your own into the Zune player and for example mark them with a Spotify icon fro branding </li>
</ul>
<p>The benefit with this would be many: Apart from not taking up precious development resources for cloning the Zune player over and over, you could let Microsoft take care of creating the most effective background enabled audio/video player. </p>
<p>To the user there is also the benefit of using the familiar way of navigating the audio as always instead of a new one for each application.</p>
<h2>Now over to the GPS application</h2>
<p>Why do you need to run this in the background? Well there are lots of reasons, but mostly it’s to be able to track and later plot your location from the track you are currently running. This functionality could also be handled with a service similar to the audio service. Why not trigger the GPS service to start tracking and storing the points. This would actually give even more advantages. This way two GPS enable applications could be using the same GPS track store and bring up the points. Again this would let the developer focusing on delivering an awesome application and not how to handle the GPS API effective enough not to drain the battery.</p>
<h2>Moving on to task scheduling</h2>
<p>There are of course situations where this approach won’t solve your issue but it’s good start to think in other directions when it comes background execution. Why not support some kind of task scheduling instead of true background operation. Here’s an example of what I mean:</p>
<p>In the GPS tracker situation there is an other issue that should be solved. The RunKeeper application vocally reports information on speed, average speed, distance, etc. This would normally be handled with an application running in the background. But it would also be possible to let simple tasks or code snippets be triggered with a set of rules based on the GPS tracker, like time, speed or distance. </p>
<p>I wouldn’t call it multitasking as the application isn’t really running in the background. It is just providing the code that should be brought back to life on certain points and then go to rest again, it can even be fully exited instead of suspended. To the user it would be of no difference if the application is running, suspended or exited as long as it behaves as if it was running in the background.</p>
<h2>Conclusion</h2>
<p>I think that in many situations we tend to take the obvious solution. While an alternative and for the user actually better way can be achieved if you think twice about it. </p>
<p>And there is an embryo to this in the Zune application, you can let your application launch the Zune player with a URL (either a net stream or locally stored) and it works great. But the API needs to be richer as I would want to insert Metadata and create lists for this as well as be able to provide a codec for handling media streams that Zune cannot play out of the box.</p>
<p>The market will continue to demand background enabling, and Microsoft will probably support that sooner rather than later but I really think we would all benefit from this thinking, both as developers and users.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2011/01/11/wp7-background-execution-really/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Windows phone 7 series mockup for for Balsamiq</title>
		<link>http://blog.jayway.com/2010/05/11/windows-phone-7-series-mockup-for-for-balsamiq/</link>
		<comments>http://blog.jayway.com/2010/05/11/windows-phone-7-series-mockup-for-for-balsamiq/#comments</comments>
		<pubDate>Tue, 11 May 2010 07:22:59 +0000</pubDate>
		<dc:creator>Håkan Reis</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[balsamiq]]></category>
		<category><![CDATA[mockup]]></category>
		<category><![CDATA[wp7dev]]></category>
		<category><![CDATA[wp7s]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=5566</guid>
		<description><![CDATA[I was trying to make a mockup in Balsamiq for a windows phone 7 series application and thought i needed a few items to get things right. So I started creating the parts needed. The basic phone, with a see-through screen so it’s easy to create panoramas to lay behind. The keyboard variants (there are [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to make a mockup in <a href="http://www.balsamiq.com/" target="_blank">Balsamiq</a> for a windows phone 7 series application and thought i needed a few items to get things right. So I started creating the parts needed. </p>
<p>The basic phone, with a see-through screen so it’s easy to create panoramas to lay behind. The keyboard variants (there are quite a few, default, text, email, web, search and a couple of dialer keyboards) and then a few of the buttons and checkboxes that’s needed. Most buttons are easiest mimicked by using the geometric shape in Balsamiq.</p>
<p>It’s quite heavy with all the details in the keyboards so pick and choose only the controls you need.</p>
<p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:1a08a95d-ac86-4b28-b738-8675d75a3c6a" class="wlWriterEditableSmartContent">
<div><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2010/05/WindowsPhone7series_panorama.zip" target="_self">WindowsPhone7series_panorama.zip</a></div>
</div>
<p><br>There you go, just download and start using it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2010/05/11/windows-phone-7-series-mockup-for-for-balsamiq/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft MIX10 brain dump</title>
		<link>http://blog.jayway.com/2010/03/18/microsoft-mix10-brain-dump-2/</link>
		<comments>http://blog.jayway.com/2010/03/18/microsoft-mix10-brain-dump-2/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 04:29:39 +0000</pubDate>
		<dc:creator>Håkan Reis</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[blend 4]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[mix10]]></category>
		<category><![CDATA[silverlight 4]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[windows phone]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/2010/03/18/microsoft-mix10-brain-dump-2/</guid>
		<description><![CDATA[Also cross-posted on my personal blog After three days of the Microsoft Mix10 event the brain tend to overflow. So I sit down at a Starbucks and try to summarize my thoughts before my mind explodes. It’s easy to get caught up in positive buzz during events like this but I really think Microsoft is [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: right;">Also cross-posted on my <a title="personal blog" href="http://blog.reis.se/post/microsoft-mix10-brain-dump.aspx" target="_blank">personal blog</a></p>
<p>After three days of the Microsoft Mix10 event the brain tend to overflow. So I sit down at a Starbucks and try to summarize my thoughts before my mind explodes.</p>
<p>It’s easy to get caught up in positive buzz during events like this but I really think Microsoft is doing a lot of things right here with Windows Phone 7 series, the next level of .NET and Silverlight and Internet Explorer 9, among other things. Some of it, I believe, accounts to all the focus on User Experience and the influence that Bill Buxton have on this.</p>
<p>Also if you want to catch any of the sessions most of them are up at the <a href="http://live.visitmix.com/Videos" target="_blank">mix10 site</a> already.</p>
<p><strong>Silverlight release pace</strong></p>
<p>This was a big surprise to me; Silverlight 4 is going to be released as early as next month end the release candidate (RC) is out now. I was more in the lines of a beta and the an RC in the summer and a release late 2010. But it seems they try to align and do a big release with .NET 4, VS2010 and Silverlight 4. As a bonus the Pivot control will be in the controls toolkit so that’s going to be fun to play with.</p>
<p><a href="http://go.microsoft.com/fwlink/?LinkID=141284">Silverlight 4 Tools RC</a> | <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=a9ef9a95-58d2-4e51-a4b7-bea3cc6962cb&amp;displaylang=en" target="_blank">.NET 4 RC</a> | <a href="http://www.microsoft.com/downloads/details.aspx?familyid=457BAB91-5EB2-4B36-B0F4-D6F34683C62A&amp;displaylang=en#filelist" target="_blank">VS2010 RC</a></p>
<p><strong>About the Windows Phone 7 series</strong></p>
<p>The development platform for Windows Phone 7 series was, of course, one of the biggest news on the starting keynote and lot of sessions around it followed. I think they are on the right track with the platform. A few surprises surfaced, like the inclusion of DirectX to utilize HW backed video decoding and the <a href="http://developer.windowsphone.com/windows-phone-7-series/" target="_blank">Windows Phone development tools</a> being released for free.</p>
<p>But a few questions and problems surfaced as well, as you can se all over the web it seems they are not including cut &amp; paste and market place being the only application deployment channel. Other things I thought about was:</p>
<ul>
<li>How is the user interface is going to perform in right to left markets.</li>
<li>What the possibilities are to hook in other services, like for example Pandora, to provide music streams for the native Zune player.</li>
<li>And I still have a few issues with lag in the interface as well as accidental clicks, lets just hope the will get this issues out the door before they release it.</li>
</ul>
<p>The user experience work that has been put into the new OS is really cool, the decision to remove all chrome and go for a real clean and consistent look is really fresh. And the decision to let the back button work on all levels across the phone, in-applications as well as between was a stroke of genius.</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2338b5d1-79d8-46af-b828-380b0f854203&amp;displaylang=en#filelist" target="_blank">Windows Phone Dev tools</a> | <a href="http://go.microsoft.com/?linkid=9713252" target="_blank">UI Design guidelines</a></p>
<p><strong>What about HTML 5 and IE 9</strong></p>
<p>It was pretty obvious that they should release some news around Internet Explorer 9 and its take on HTML 5. It is just an early technology preview but I have to say I’m impressed by the results. They did tone down the JavaScript speed issues but quite frankly they were on par with the other browsers and at those speeds it really is less of an issue. What still is an issue is standards, and anything but a 100/100 score on Acid3 is a failure in my eyes.</p>
<p>What they did show was the brilliant work they have done on the GPU acceleration part. This really was amazing 720p HD video streaming on a netbook was blazing fast, they even manage to pump two 720p streams without a glitch, impressive. And rendering HMTL5, CSS3 and SVG with hardware acceleration really looks promising.</p>
<p>If anything it shows that the Internet Explorer team is still in the game and might really get a decent browser out the door.</p>
<p><a href="http://ie.microsoft.com/testdrive/info/ThankYou/Default.html" target="_blank">IE9 platform preview</a></p>
<p><strong>Expression Blend 4</strong></p>
<p>The things I saw done with blend was quite cool, this tool has come a long way from the first release and is now a potent tool. The tight integration with Adobe was finally in place, just point to the assets and start editing it in Illustrator or Photoshop. What’s more impressive, if I got it right, was that you were able to bind to a text object from the imported Illustrator assets directly to the object in your ViewModel! This really puts design control back into the hands of the designer.</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=6f014e07-0053-4aca-84a7-cd82f9aa989f&amp;displaylang=en" target="_blank">Expression Blend 4 beta</a></p>
<p><strong><a href="http://oredev.org/2010/call-for-papers" target="_blank">Get real</a></strong></p>
<p>So what’s left for me now is to find the time to play with all these new toys and and experience for myself what they are capable of before it’s time to <a href="http://oredev.org/2010/call-for-papers" target="_blank">Get Real</a> and start creating.</p>
<p>Have fun // <a title="blog. reis se" href="http://blog.reis.se" target="_blank">Håkan Reis</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2010/03/18/microsoft-mix10-brain-dump-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get nagged about keyboard shortcuts in Eclipse</title>
		<link>http://blog.jayway.com/2009/11/12/get-nagged-about-keyboard-shortcuts-in-eclipse/</link>
		<comments>http://blog.jayway.com/2009/11/12/get-nagged-about-keyboard-shortcuts-in-eclipse/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 08:29:08 +0000</pubDate>
		<dc:creator>Tobias Södergren</dc:creator>
				<category><![CDATA[User Experience]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=2226</guid>
		<description><![CDATA[I was attending the "The Productive Programmer: Mechanics" session, held by Neal Ford, at Oredev last week and I wanted to share one trick that will more or less force you to get faster when developing in Eclipse. The Eclipse plug-in MouseFeed, written by Andriy Palamarchuk, will repeatedly nag you with what keyboard shortcuts you [...]]]></description>
			<content:encoded><![CDATA[<p>I was attending the "The Productive Programmer: Mechanics" session, held by Neal Ford, at Oredev last week and I wanted to share one trick that will more or less force you to get faster when developing in Eclipse.</p>
<p>The Eclipse plug-in MouseFeed, written by Andriy Palamarchuk, will repeatedly nag you with what keyboard shortcuts you can use instead of using the mouse to perform actions. For example, if you constantly left-mouse-click the "step-over" button in the debug perspective, the MouseFeed plug-in will pop-up a notification window telling you to instead press "F6" on your keyboard. </p>
<p>You can also make the plug-in even more annoying by having MouseFeed canceling the mouse operation so that you have to use the keyboard shortcut.</p>
<p>I have installed it and forgotten about it until today, when it gently reminded me that collapsing all nodes in the Package Explorer view could be issued by "Shift-Command Numpad_Divide" on Mac OS X. Unfortunately my laptop does not come with a numeric keyboard so I have better to remap the shortcut if I find myself collapsing nodes often.</p>
<p>The MouseFeed home page can be found at: <a href="http://www.mousefeed.com">http://www.mousefeed.com</a><br />
The SourceForge project page: <a href="http://sourceforge.net/projects/mousefeed/">http://sourceforge.net/projects/mousefeed</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/11/12/get-nagged-about-keyboard-shortcuts-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Lacking a domain expert will get you into trouble</title>
		<link>http://blog.jayway.com/2009/09/24/lacking-a-domain-expert-will-get-you-into-trouble/</link>
		<comments>http://blog.jayway.com/2009/09/24/lacking-a-domain-expert-will-get-you-into-trouble/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 04:17:05 +0000</pubDate>
		<dc:creator>Rickard Öberg</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[User Experience]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=1981</guid>
		<description><![CDATA[For our new StreamFlow project I wanted to try and get management functions in properly right from the start, which basically means exposing configuration, service management and administrator functions through JMX. I figured that if I did that on my part the customer would simply be able to get a decent JMX console and get their work done efficiently through that.

But then yesterday I did some research into the current state of JMX consoles, and in particular downloaded and tested all the OpenSource consoles in Java. The end result of that is a realization that they all basically suck. There's no point in naming names, and no point in going into detail, because they all seem to have the same basic problem: the developers haven't talked to a domain expert.]]></description>
			<content:encoded><![CDATA[<p><em>The following entry was originally posted on Rickard's blog.</em></p>
<p>For our new StreamFlow project I wanted to try and get management functions in properly right from the start, which basically means exposing configuration, service management and administrator functions through JMX. I figured that if I did that on my part the customer would simply be able to get a decent JMX console and get their work done efficiently through that.</p>
<p>But then yesterday I did some research into the current state of JMX consoles, and in particular downloaded and tested all the OpenSource consoles in Java. The end result of that is a realization that they all basically suck. There's no point in naming names, and no point in going into detail, because they all seem to have the same basic problem: the developers haven't talked to a domain expert.</p>
<p>Don't get me wrong, these consoles have lots of features, and the features work. It's just that those features are not helping administrators get their work done, and the features that would help them get their work done are missing. If the developers of these consoles had talked to actual system administrators to figure out what they need to get their work done, I'm quite certain that the consoles would have far less features, but the features they had would actually be useful. Kind of like a Mac-experience I guess.</p>
<p>This seems to be one of the profound and obvious insights of Domain Driven Design: you can't get it right by guessing what your users want. You have to actually talk to them and ask them what they want, why they want it, and what problems it will solve. Most software today, especially in the packaged product sphere, seems to be done by developers who are sort of guessing what to include based on their own ideas and possibly what the sales guys and marketing folks think would make the product more sellable. But that doesn't mean that the end result will be useful or even usable, and it's a big fundamental problem with our industry.</p>
<p>As software developers we need to understand that having strong development skills is not enough. We also have to take the time to understand what it is our customers are doing, how they are doing it, and why. We have to be cross-disciplinary, to a large extent, or else our products will inevitably be doing things nobody really asked for. We will be creating waste, and lots of it.</p>
<p>So to the makers of JMX consoles in particular, here are some suggestions. Look into DDD. Look into BDD, Behaviour Driven Design, also, as this will give you the simple tool of "As an X I want to Y so that Z", which will profoundly help you sort out the useful features from the useless features. "As an Administrator I want to Know when a server goes down so that Users won't have to tell me". Things like that. Then get a domain expert or two. Talk to them. Learn what they do, how they do it, and what they need to get things done. Learn their ubiquitous language. Then implement features that would actually help them. I guarantee you that if you start from scratch and follow this model you'll be pretty far along after just 10 features, and none of them will be similar to what you already have in the consoles today. But they will be useful! And that is a good start.</p>
<p><em>ps. while the lack of decent OpenSource JMX consoles is depressing, during my tests I did find one product that seems really good, and have features that are related to things that administrators care about: the <a href="http://www.manageengine.com/products/applications_manager/index.html">ManageEngine Applications Manager</a>. Check it out!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/09/24/lacking-a-domain-expert-will-get-you-into-trouble/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mavenizing the Liferay Plugin SDK</title>
		<link>http://blog.jayway.com/2009/03/14/mavenizing-the-liferay-plugin-sdk/</link>
		<comments>http://blog.jayway.com/2009/03/14/mavenizing-the-liferay-plugin-sdk/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 08:58:00 +0000</pubDate>
		<dc:creator>Henrik Bernström</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[archetype]]></category>
		<category><![CDATA[artifact]]></category>
		<category><![CDATA[liferay]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[maven2]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[portlet]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=1094</guid>
		<description><![CDATA[Liferay is the leading Open Source enterprise portal platform in the Java market. It's certainly an impressive piece of software. I've been following it for some time now and the product is improving a great deal in many areas, perhaps most in end user usability. One area that, in my opinion, could still be improved [...]]]></description>
			<content:encoded><![CDATA[<p>Liferay is the leading Open Source enterprise portal platform in the Java market. It's certainly an impressive piece of software. I've been following it for some time now and the product is improving a great deal in many areas, perhaps most in end user usability.</p>
<p>One area that, in my opinion, could still be improved is the development environment. It may be a heck of a good build system <a href="http://www.liferay.com">Liferay</a> has come up with, but at the bottom line it takes time to learn it and to just start studying it you easily become a bit uncertain. It consists of homegrown ant scripts. To have a flatter learning curve for newcomers <a href="http://maven.apache.org/">Maven 2</a> might be suitable.</p>
<p>Anyway, I sat down one evening some time ago and looked into how Maven 2 could be used for creating Jsp Portlets for Liferay. Some hours later the work had resulted in a new archetype for creating Liferay Jsp Portlets. </p>
<p><a href="http://svn.liferay.com/browse/plugins/trunk/tools/portlet_tmpl">The structure and content of the standard Liferay Jsp Portlet can be viewed here.</a></p>
<h3>So, what did I do?</h3>
<p>1. I followed these instructions to manipulate the Jsp Portlet part of Liferay's plugin SDK into a maven archetype:</p>
<p><a href="http://maven.apache.org/guides/mini/guide-creating-archetypes.html">http://maven.apache.org/guides/mini/guide-creating-archetypes.html</a></p>
<p>This involved editing these property and xml files:</p>
<pre>liferay-plugin-package.properties
name=${artifactId}
module-group-id=liferay
module-incremental-version=1
tags=
short-description=
change-log=
page-url=http://www.liferay.com
author=Liferay, Inc.
licenses=MIT
</pre>
<pre class="xml">portlet.xml
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="font-weight: bold; color: black;">?&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet-app</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>jspPortlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;display-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>${artifactId}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/display-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet-class<span style="font-weight: bold; color: black;">&gt;</span></span></span>${groupId}.JSPPortlet<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet-class<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;init-param<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;name<span style="font-weight: bold; color: black;">&gt;</span></span></span>view-jsp<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;value<span style="font-weight: bold; color: black;">&gt;</span></span></span>/view.jsp<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/value<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/init-param<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;expiration-cache<span style="font-weight: bold; color: black;">&gt;</span></span></span>0<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/expiration-cache<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;supports<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mime-type<span style="font-weight: bold; color: black;">&gt;</span></span></span>text/html<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/mime-type<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/supports<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;portlet-info<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;title<span style="font-weight: bold; color: black;">&gt;</span></span></span>${artifactId}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/title<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;short-title<span style="font-weight: bold; color: black;">&gt;</span></span></span>${artifactId}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/short-title<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;keywords<span style="font-weight: bold; color: black;">&gt;</span></span></span>${artifactId}<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/keywords<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet-info<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>administrator<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>guest<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>power-user<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>user<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/role-name<span style="font-weight: bold; color: black;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/security-role-ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/portlet-app<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p>to insert ${artifactId} and ${groupId} for the portlet name and package structure. These files are part of the file list finally being wrapped up within the archetype and used to generate the resulting portlet from Maven 2.</p>
<p>2. I ran '<strong>mvn install</strong>' on that particular archetype to have it installed in my local repository.</p>
<p>3. I used the archetype to create a new Liferay Jsp Portlet artifact:</p>
<pre>
mvn archetype:create -DarchetypeGroupId=com.liferay.maven.archetypes.portlet.jsp
  -DarchetypeArtifactId=liferay-jsp-portlet
  -DarchetypeVersion=1.0-SNAPSHOT
  -DgroupId=[my.package]
  -DartifactId=[MyFirstLiferayJspPortlet]
</pre>
<p>4. I stepped into the artifact and ran '<strong>mvn install</strong>' on it which generated my MyFirstLiferayJspPortlet-1.0-SNAPSHOT.war.</p>
<p>5. I then uploaded the war file to my portal instance via the Liferay admin GUI Plugin Installer.</p>
<p>6. Et voila. It worked, showing up in the portal.</p>
<p>And of course, worth mentioning, to have a development environment up and running in eclipse in seconds this is all you have to do:</p>
<pre>
1. mvn eclipse:add-maven-repo -Declipse.workspace=[full-path-to-workspace]

2. mvn eclipse:eclipse
</pre>
<p>To have the archetype play with the existing build situation of Liferay it would probably need to be generated from some ant target and be based on the portlet template in subversion located at "plugins/tools/portlet_tmpl/" to have it follow updates of Liferay.</p>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2009/03/jspportlet-archetype.zip">Here you can download the final result, as a zipped archetype.</a></p>
<p>If a generated archetype like this was to be uploaded to a public maven repository, working from above point #3 and down is what would be necessary for a developer to have a project and all the necessary property and xml files (correctly edited with package structures and all) in place for a Liferay Jsp Portlet development environment. It could at least become a complement to the Plugins SDK. And yes, it could for sure still be enhanced. For example, there is no JSPPortletTest class generated for the JSPPortlet class.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/03/14/mavenizing-the-liferay-plugin-sdk/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>iPhone Tech Talks &#8211; Stockholm</title>
		<link>http://blog.jayway.com/2008/12/09/iphone-tech-talks-stockholm/</link>
		<comments>http://blog.jayway.com/2008/12/09/iphone-tech-talks-stockholm/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 09:03:51 +0000</pubDate>
		<dc:creator>Fredrik Olsson</dc:creator>
				<category><![CDATA[Embedded]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sdk]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=535</guid>
		<description><![CDATA[Apple has arranged a world tour of iPhone Tech Talks, and in cold december it was Scandinavia's turn and a crew of software evangelists from Apple turned up at KTH in Stockholm for a full day of sessions. The sessions are confidential so I will keep this post vague on the technical parts, not revealing [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.apple.com">Apple</a> has arranged a world tour of <a href="http://developer.apple.com/events/iphone/techtalks/">iPhone Tech Talks</a>, and in cold december it was Scandinavia's turn and a crew of software evangelists from Apple turned up at <a href="http://www.kth.se/">KTH</a> in Stockholm for a full day of sessions.</p>
<p>The sessions are confidential so I will keep this post vague on the technical parts, not revealing any thing that might or might not come to an iPhone or iPod touch near you in the future. And I can not mention any specific sales numbers, but I do can say that any predicted numbers you might have seen; is probably an underestimation with a margin and then some.</p>
<p>The sessions where on a high level, not going too deep on technical details. Instead the sessions concentrated on the overall design philosophies, and common gotchas. For the nitty gritty details Apple engineers where available, and I missed half a session discussing the ins and outs of the UIToolbar class with Alberto Arauz. Alberto is one of the european software evangelist, and was most impressed, and interested, when I described the successful <a href="http://www.oredev.org/topmenu/program/trackmobile20.4.2c4b8bee11a31fca49e8000319.html">Mobile 2.0 track</a> at <a href="http://www.oredev.org">Øredev 2008</a>. Apple's overall impression with Scandinavia has so far been a mostly cold hand regarding anything with Apple, going as far as only six people registering for a Tech Talk in Oslo two years ago.</p>
<p>Apart from the speakers and engineers, Apple also brought a video-team. So yours truly has been intervjued about the <a href="http://www.peylow.se/">applications I have</a> on App Store, and my experience with the iPhone SDK. The video will be cut and edited for promotional purposes, and hopefully me mentioning both Malmö and Jayway will not be cut out. The odds of my short talk being included is quite good, as most developers seems to be focusing on games, not utilities as I and Jayway has done.</p>
<p>The best part to take home is not technical, just solid advice for any development, not even under NDA, and the sole point repeated by Apple over and over: <strong>Developing great applications is not about adding features!</strong> The trick is not to cram in as many features as you can, the trick is to know what features to leave out, so that time can be well spend on the key features that do make the cut. And this is tenfold as important on a mobile device where real estate is limited. A quote from Mark Twain:</p>
<blockquote><p>I apologize for writing you a long letter, but I did not have the time to write a short.</p></blockquote>
<p>Writing short, and cutting features is hard. How to decide on the features to drop or implement? Apple uses a simple technique, called a product statement. The product statement for the Photos application is for example; <em>"An easy to use photo sharing application for all iPhone users"</em>. Any feature that do not help fulfilling this statement do not make it. How about simple photo-editing? Nope, does not comply with statement. The wording of the product statement is important, by simply changing it to <em>"An easy to use photo sharing application for <u>professional photographers</u>"</em>, would be a completely new application. Only when the product statement is agreed upon, can an approved list of features be made. An omnipresent Steve Jobs approving and dismissing features, is an exaggeration, this simple method is what do the trick.</p>
<p>Now this might sound both obvious, and counterintuitive. Surely adding that last nice feature would add value? Not at the expense of a cluttered user interface, that is meant to be used while standing in line for 30 seconds. Features thought to be must haves, most of the time are not. Some features thought to be must haves are MMS and video recording. Looking at the raging success of the iPhone, it is very obvious that they are not must haves. We as software engineers must at long last learn that it truly is quality over quantity.</p>
<p>And lastly a personal reflection; from a developer's point of view the best part about iPhone SDK is that it is not an UI framework, it is an Application framework. It do not settle with providing the tools for collections, persisting data, displaying a UI, and then leave the rest of the architecture to the developers. The iPhone SDK supports all three parts of the Model-View-Controller paradigm equally well, and that is what makes it so productive.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2008/12/09/iphone-tech-talks-stockholm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making APIs usable</title>
		<link>http://blog.jayway.com/2006/10/01/making-apis-usable/</link>
		<comments>http://blog.jayway.com/2006/10/01/making-apis-usable/#comments</comments>
		<pubDate>Sun, 01 Oct 2006 14:56:49 +0000</pubDate>
		<dc:creator>Mattias Ask</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[jayview]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=3776</guid>
		<description><![CDATA[All APIs have end-users. How and whether these users use a certain API depends on how useful the API is to them. This in turn is determined by what problem the API solves, how easy it is to learn and understand, and how easy it is to use. This article will give some (perhaps obvious) [...]]]></description>
			<content:encoded><![CDATA[<p><strong>All APIs have end-users. How and whether these users use a certain API depends on how useful the API is to them. This in turn is determined by what problem the API solves, how easy it is to learn and understand, and how easy it is to use. This article will give some (perhaps obvious) pointers on how to improve ease-of-learning and ease-of-use of your API. </strong></p>
<p>Usability is the science of usage which means that usability rules and laws apply to rich clients, web applications, paper forms, furniture, milk cartons, tools etc. It needs to be taken into consideration whenever there is a human end-user. If not, the product will be designed to be specifically useful to the designer. </p>
<h2>Know your user </h2>
<p>The first question to ask yourself is: Who is going to use your API? If you know that<br />
then you are half way to the bank. Why? Simply because you know what your users<br />
know and want, and thus you can give them what they need.<br />
If the user has a list of objects and wants to remove objects which already exists in<br />
another list, your API could look something like this: </p>
<pre>CustomList myList = getMyList();
CustomList yourList = getYourList();
myList.removeSharedItems(yourList);
</pre>
<p>“myList.removedSharedItems(yourList);” describes what the function does to your<br />
list, and is suited for most any programmer. If, on the other hand, you <strong>know</strong> that<br />
your users are working with <strong>set theory</strong>, you would probably want to do something<br />
like this: </p>
<pre>CustomList myList = getMyList();
CustomList yourList = getYourList();
myList.toRelativeComplement(yourList);
</pre>
<h2>Let the API be self-documenting </h2>
<p>Remember that when it comes to learning or getting started with an API, many pro-<br />
grammers simply rely on the AutoCompletion-function in their IDE. If they don’t<br />
get it from looking at that, they might turn to the documentation, or simply turn to<br />
another competing API. So don’t take naming your classes and methods lightly.<br />
In the previous example both </p>
<pre>myList.removeSharedItems(yourList);</pre>
<p>..and: </p>
<pre>myList.toRelativeComplement(yourList);</pre>
<p>..mutate myList. This is visualised by using “remove” and “to” which both refer<br />
to the myList-object. If for example “myList.toRelativeComplement (yourList);”<br />
didn’t have the word “to”, the user wouldn’t know if it returns the relative comple-<br />
ment or if it mutates myList to it.<br />
In SpringFramework, self-explanatory class names such as “BatchPreparedState-<br />
mentSetter” (an interface for a prepared statement setters used during batch up-<br />
dates) are widely used. The only risk with this is that class-, interface- and method<br />
names can get rather long, resulting in poorer readability. Explain what it does but<br />
be as precise as possible and don’t take it to the extreme. </p>
<h2>Don’t present the underlying implementation </h2>
<p>The API should limit itself to what the user needs to know; no more, no less. The<br />
names of classes, interfaces and methods should describe what they do and what<br />
they are used for; not how they do it. Why force the user to know what the underly-<br />
ing implementation does if they don’t need to know? Open-source your code and<br />
give the user the choice to see how it is done instead of forcing it on them.<br />
Java.io.Properties.loadFromXML takes an InputStream. This means that to load<br />
properties from XML the following needs to be done. </p>
<pre>File myProps = new File(“.\\MyProps.xml”);
FileInputStream is = new FileInputStream(myProps);
Properties p = new Properties();
//void loadFromXML(InputStream in)
p.loadFromXML(is);
</pre>
<p>The fact that loadFromXML takes an InputStream describes what the method does.<br />
A better solution would be to look at SpringFramework’s Resource solution. There<br />
they have a common interface called “Resource” which is implemented by every-<br />
thing from FileSystemResource to InputStreamResource. If java.io.File were to im-<br />
plement such an interface, a solution could simply be: </p>
<pre>Properties p = new Properties();
//void loadFromXML(Resource xmlResource)
p.loadFromXML(new File(“.\\MyProps.xml”));</pre>
<p>In this case the user of the API doesn’t have to think about <strong>in what way</strong> the XML<br />
will be read; just that it <strong>will be</strong> read. </p>
<h2>Think of logical mapping</h2>
<p>The methods of a class (name and responsibility) must map well to the classes<br />
name; input and output of a method must map the responsibility of the method and<br />
so on. If this is done, the user will be able to use the API intuitively, and learn and<br />
understand how to use it without any documentation. </p>
<pre>//Bad mapping in Calendar
void setTime(Date date)
//Better mapping
void setTime(Time time)
</pre>
<h2>Limit the number of options </h2>
<p>If you have something in your API that can be done in two different ways, choose<br />
one. Don’t give the user an ambiguous API with features that are so similar that it is<br />
confusing, and force them to go to the documentation or choose by chance. </p>
<pre>myCalendar.add(Calendar.DAY_OF_WEEK,7);
//...differs from...
myCalendar.roll(Calendar.DAY_OF_WEEK,7);
//...in what way?
</pre>
<h2>Avoid methods and classes that do<br />
different things in different object states<br />
</h2>
<p>Separate your domain entities in such a way that they overlap as little as possible.<br />
This is basic OO and should be common sense, but it is a common problem. Java.<br />
io.File has exactly this problem. An object of java.io.File can be a File or a Directory.<br />
If the object is created from the path of a directory it is a directory. This gives the<br />
possibility to write, among other things, the following illogical code: </p>
<pre>File myFile = new File(“.\\MyFile.xml”);
boolean dirMade = myFile.mkDir();
</pre>
<p>A better solution would be if File were structured something like: </p>
<pre>interface FileSystemElement extends Resource{
   //...
}
class abstract AbstractFileSystemElement implements FileSystemElement{
   //...
} 

class File extends AbstractFileSystemElement{
   //...
} 

class Directory extends AbstractFileSystemElement{
   //...
} </pre>
<h2>Summary </h2>
<p>The most important thing to remember is that there is a human user at the other<br />
end of an API. If you remember this you will create better APIs. The pointers in this<br />
article simply scratch the surface of what could be done to improve your APIs. One<br />
thing that would result in great improvements is if you found a couple of users and<br />
user-tested the solution. (<a href="http://en.wikipedia.org/wiki/Usability_testing">http://en.wikipedia.org/wiki/Usability_testing</a>). </p>
<p><em>Originally published in <a href="http://jayway.se/jayview">JayView</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2006/10/01/making-apis-usable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tired of Date and Calendar?</title>
		<link>http://blog.jayway.com/2006/09/16/tired-of-date-and-calendar/</link>
		<comments>http://blog.jayway.com/2006/09/16/tired-of-date-and-calendar/#comments</comments>
		<pubDate>Sat, 16 Sep 2006 12:56:39 +0000</pubDate>
		<dc:creator>Ulrik Sandberg</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[jodatime]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=250</guid>
		<description><![CDATA[It's not always easy to decide whether to add yet another dependency to yet another framework. It's especially hard when it's about a very central part of the JDK, like Date and Calendar. They are not great, there's little doubt about that. However, the benefits of a new framework would have to be numerous in [...]]]></description>
			<content:encoded><![CDATA[<p>It's not always easy to decide whether to add yet another dependency to yet another framework. It's especially hard when it's about a very central part of the JDK, like Date and Calendar. They are not great, there's little doubt about that. However, the benefits of a new framework would have to be numerous in order for us to make the switch. It must also be simple to convert between the standard classes and the framework classes. The impact on our project must be minimal. Ideally, it would be a question of dropping in a single jar-file. This article not only finds the weak spots of Date and Calendar, but also presents a compelling alternative.</p>
<h3>How bad are Date and Calendar?</h3>
<p>Consider <code>java.util.Date</code>. It has been around since JDK 1.0, and it's actually not a date, but a date and a time. In order to get the date (and the time), you call the <code>getTime()</code> method. It uses two-digit years from 1900, day-of-month is one-based, while month and hours are zero-based, it should have been immutable, and most methods have been deprecated in JDK 1.1. Since it's not final, it's possible to hack it by overriding critical methods, like for example <code>after</code>.</p>
<p>The state of <code>java.util.Calendar</code> is not much better. Month is zero-based, it should have been immutable, and it allows only one hour offset for daylight savings time. Some years have more, you know. British timezone in 1943, 1944 and 1945, for example, had two hours. The worst part is that it uses two different representations internally: a value for each field, and milliseconds since 1970. The scary part is that these two representations are not continuously kept in synch. Instead they are resynched as a side effect of other method calls, like <code>equals</code> for example. Wouldn't that be something? You call <code>equals</code> on your <code>Calendar</code> and suddenly it changes to a different date.</p>
<p>Then we have <code>java.util.SimpleDateFormat</code>. It requires a <code>Date</code> object, it's not very fast, and it's not thread-safe. If concurrent threads call its <code>format</code> method on a shared instance, it can produce bizarre results.</p>
<h4>They can't be that bad, can they?</h4>
<p>Let's print out a date. We want July 2, 1945 and the time should be 12.30 PM. Here we go:</p>
<pre class="java">&nbsp;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ADate+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Date</span></a> date = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ADate+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Date</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1945</span>, <span style="color: #cc66cc;">7</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">30</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>date.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Sat Aug 02 12:30:00 CEST 3845</span>
&nbsp;</pre>
<p>Oops. Forgot the two-digit year and the zero-based month. Let's try again:</p>
<pre class="java">&nbsp;
<span style="color: #993333;">int</span> year = <span style="color: #cc66cc;">1945</span> - <span style="color: #cc66cc;">1900</span>;
<span style="color: #993333;">int</span> month = <span style="color: #cc66cc;">7</span> - <span style="color: #cc66cc;">1</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ADate+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Date</span></a> date = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ADate+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Date</span></a><span style="color: #66cc66;">&#40;</span>year, month, <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">30</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>date.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Mon Jul 02 12:30:00 CEST 1945</span>
&nbsp;</pre>
<p>Yes, I know that the constructor used above is deprecated. This is how it really should be done:</p>
<pre class="java">&nbsp;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ATimeZone+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">TimeZone</span></a> tz = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ATimeZone+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">TimeZone</span></a>.<span style="color: #006600;">getTimeZone</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Asia/Tokyo&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a> cal = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a>.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span>tz<span style="color: #66cc66;">&#41;</span>;
cal.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1945</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a>.<span style="color: #006600;">JULY</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">30</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ADateFormat+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">DateFormat</span></a> f= <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASimpleDateFormat+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">SimpleDateFormat</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;yyyy-MM-dd hh:mm&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>f.<span style="color: #006600;">format</span><span style="color: #66cc66;">&#40;</span>cal<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// java.lang.IllegalArgumentException: Cannot format given Object as a Date</span>
<span style="color: #808080; font-style: italic;">// at java.text.DateFormat.format(DateFormat.java:279)</span>
<span style="color: #808080; font-style: italic;">// at java.text.Format.format(Format.java:133)</span>
&nbsp;</pre>
<p>Oops. <code>DateFormat</code> cannot take a <code>Calendar</code>. Let's try with a <code>Date</code>:</p>
<pre class="java">&nbsp;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ATimeZone+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">TimeZone</span></a> tz = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ATimeZone+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">TimeZone</span></a>.<span style="color: #006600;">getTimeZone</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Asia/Tokyo&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a> cal = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a>.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span>tz<span style="color: #66cc66;">&#41;</span>;
cal.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1945</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a>.<span style="color: #006600;">JULY</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">30</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ADateFormat+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">DateFormat</span></a> f= <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASimpleDateFormat+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">SimpleDateFormat</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;yyyy-MM-dd hh:mm&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ADate+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Date</span></a> date = cal.<span style="color: #006600;">getTime</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>f.<span style="color: #006600;">format</span><span style="color: #66cc66;">&#40;</span>date<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// 1945-07-02 06:30</span>
&nbsp;</pre>
<p>Well, almost right. I asked for the time to be 12.30, not 6.30. Ah, of course. It's not enough to set the timezone on the <code>Calendar</code> that we used to get the <code>Date</code> that we want to print. The <code>DateFormat</code> that prints the <code>Date</code> also needs the timezone. Silly me.</p>
<pre class="java">&nbsp;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ATimeZone+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">TimeZone</span></a> tz = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ATimeZone+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">TimeZone</span></a>.<span style="color: #006600;">getTimeZone</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Asia/Tokyo&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a> cal = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a>.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span>tz<span style="color: #66cc66;">&#41;</span>;
cal.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1945</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Calendar</span></a>.<span style="color: #006600;">JULY</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">30</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ADateFormat+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">DateFormat</span></a> f= <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASimpleDateFormat+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">SimpleDateFormat</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;yyyy-MM-dd hh:mm&quot;</span><span style="color: #66cc66;">&#41;</span>;
f.<span style="color: #006600;">setTimeZone</span><span style="color: #66cc66;">&#40;</span>cal.<span style="color: #006600;">getTimeZone</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ADate+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Date</span></a> date = cal.<span style="color: #006600;">getTime</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>f.<span style="color: #006600;">format</span><span style="color: #66cc66;">&#40;</span>date<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// 1945-07-02 12:30</span>
&nbsp;</pre>
<p>Finally.</p>
<h3>The Contender: Joda-Time</h3>
<p>There is a candidate that has all the characteristics we mentioned earlier, and more: <a href="http://joda-time.sourceforge.net/index.html">Joda-Time</a>. It's a single jar of 518k with no other dependencies. It replaces <code>Date</code>, <code>Calendar</code> and <code>TimeZone</code>. It has interfaces for datetimes, intervals and durations. The key classes are immutable. It has a pluggable calendar system where the default is ISO8601. And one more thing: it's easy to use.</p>
<h4>DateTime</h4>
<p>The most useful class in Joda-Time is the <code>DateTime</code>, which is immutable and thread-safe. It is measured in milliseconds since 1970, and it has simple getters for all fields. It supports timezones and multiple calendar systems. Its main purpose is to fill the most common needs as simple as possible:</p>
<pre class="java">&nbsp;
DateTime now = <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #993333;">int</span> y = now.<span style="color: #006600;">getYear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333;">int</span> hour = now.<span style="color: #006600;">getHourOfDay</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333;">int</span> sec = now.<span style="color: #006600;">getSecondOfMinute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #993333;">boolean</span> leap = now.<span style="color: #006600;">year</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">isLeap</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333;">int</span> daysInMonth = now.<span style="color: #006600;">dayOfMonth</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">getMaximumValue</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>Since it's immutable, all mutating methods return new objects:</p>
<pre class="java">&nbsp;
DateTime now = <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
DateTime yesterday = now.<span style="color: #006600;">minusDays</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">plusHours</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<h4>Partial</h4>
<p>Partially defined datetimes have no timezone; they use local time. They are called "partial" because they don't have all the fields of a <code>DateTime</code>. We have <code>YearMonthDay</code>, <code>TimeOfDay</code> (hour, minute, second, and millisecond), and <code>Partial</code> (can store any fields). They can easily be converted to <code>DateTime</code>:</p>
<pre class="java">&nbsp;
YearMonthDay ymd = <span style="color: #000000; font-weight: bold;">new</span> YearMonthDay<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2005</span>, <span style="color: #cc66cc;">9</span>, <span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// September 20, 2005</span>
TimeOfDay tod = <span style="color: #000000; font-weight: bold;">new</span> TimeOfDay<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">14</span>, <span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
DateTimeZone zone = DateTimeZone.<span style="color: #006600;">forID</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Asia/Tokyo&quot;</span><span style="color: #66cc66;">&#41;</span>;
DateTime dt = ymd.<span style="color: #006600;">toDateTimeAtCurrentTime</span><span style="color: #66cc66;">&#40;</span>zone<span style="color: #66cc66;">&#41;</span>;
DateTime dt2 = ymd.<span style="color: #006600;">toDateTime</span><span style="color: #66cc66;">&#40;</span>tod<span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<h4>Period</h4>
<p>A <code>Period</code> represents a period of time, like "5 years, 3 months, 2 days and 12 hours":</p>
<pre class="java">&nbsp;
Period period = <span style="color: #000000; font-weight: bold;">new</span> Period<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5</span>, <span style="color: #cc66cc;">3</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333;">int</span> years = period.<span style="color: #006600;">getYears</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333;">int</span> days = period.<span style="color: #006600;">getDays</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<h4>Interval</h4>
<p>The class <code>Interval</code> represents an interval of time, represented by a start <code>DateTime</code> (included) and an end <code>DateTime</code> (excluded). Let's say we want to know how many complete weeks an interval is. To do that, we convert the <code>Interval</code> to a <code>Period</code> of the specific type we want. Using <code>PeriodType</code>, we can deduce that the interval below is 9 complete weeks (<code>P9W</code> is ISO8601-standard for a 9 week period):</p>
<pre class="java">&nbsp;
DateMidnight start = <span style="color: #000000; font-weight: bold;">new</span> DateMidnight<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2005</span>, <span style="color: #cc66cc;">7</span>, <span style="color: #cc66cc;">12</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// July 12, 2005</span>
DateMidnight end = <span style="color: #000000; font-weight: bold;">new</span> DateMidnight<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2005</span>, <span style="color: #cc66cc;">9</span>, <span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// September 15, 2005</span>
Interval interval = <span style="color: #000000; font-weight: bold;">new</span> Interval<span style="color: #66cc66;">&#40;</span>start, end<span style="color: #66cc66;">&#41;</span>;
Period period = interval.<span style="color: #006600;">toPeriod</span><span style="color: #66cc66;">&#40;</span>PeriodType.<span style="color: #006600;">weeks</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>period<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// P9W</span>
&nbsp;</pre>
<h4>Chronology</h4>
<p>Joda-Time features a pluggable calendar system based on the <code>Chronology</code> class. There are for example ISO9601, Gregorian, Julian, GJ, Buddhist, Ethiopic, and Coptic. The default is <code>ISOChronology</code>. A <code>Chronology</code> can be passed in as extra parameter whenever needed, as in the following example where we print the year 2006 as the Buddhists see it:</p>
<pre class="java">&nbsp;
Chronology buddhist = BuddhistChronology.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
DateTime now = <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #66cc66;">&#40;</span>buddhist<span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333;">int</span> year = now.<span style="color: #006600;">getYear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// 2006</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>year<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// 2549</span>
&nbsp;</pre>
<h4>Time Zone</h4>
<p>The <code>DateTimeZone</code> class encapsulates a time zone that contains not only the timezones in the current JDK implementations, but is also up to date with the most current time zone data available at the <a href="http://www.twinsun.com/tz/tz-link.htm">time zone database</a>.</p>
<pre class="java">&nbsp;
DateTimeZone.<span style="color: #006600;">UTC</span>;
DateTimeZone.<span style="color: #006600;">forID</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Asia/Tokyo&quot;</span><span style="color: #66cc66;">&#41;</span>;
DateTimeZone.<span style="color: #006600;">forOffsetHours</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span>;
DateTimeZone.<span style="color: #006600;">forTimeZone</span><span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ATimeZone+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">TimeZone</span></a>.<span style="color: #006600;">getTimeZone</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Europe/Stockholm&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>One problem with the JDK <code>TimeZone</code> is that it returns timezone UTC (also known as GMT) if the full name cannot be understood:</p>
<pre class="java">&nbsp;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ATimeZone+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">TimeZone</span></a> validTz = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ATimeZone+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">TimeZone</span></a>.<span style="color: #006600;">getTimeZone</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Asia/Tokyo&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>validTz<span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ATimeZone+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">TimeZone</span></a> invalidTz = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ATimeZone+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">TimeZone</span></a>.<span style="color: #006600;">getTimeZone</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Asia/SomeUnknownCity&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>invalidTz<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// sun.util.calendar.ZoneInfo[id=&quot;Asia/Tokyo&quot;,offset=32400000,dstSavings=0,useDaylight=false,...</span>
<span style="color: #808080; font-style: italic;">// sun.util.calendar.ZoneInfo[id=&quot;GMT&quot;,offset=0,dstSavings=0,useDaylight=false,...</span>
&nbsp;</pre>
<p>By contrast, Joda-Time's <code>DateTimeZone</code> throws an <code>IllegalArgumentException</code> if it cannot understand the time zone name:</p>
<pre class="java">&nbsp;
DateTimeZone validTz = DateTimeZone.<span style="color: #006600;">forID</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Asia/Tokyo&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>validTz<span style="color: #66cc66;">&#41;</span>;
DateTimeZone invalidTz = DateTimeZone.<span style="color: #006600;">forID</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Asia/SomeUnknownCity&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>invalidTz<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Asia/Tokyo</span>
<span style="color: #808080; font-style: italic;">// java.lang.IllegalArgumentException: The datetime zone id is not recognised: Asia/SomeUnknownCity</span>
<span style="color: #808080; font-style: italic;">// at org.joda.time.DateTimeZone.forID(DateTimeZone.java:198)</span>
&nbsp;</pre>
<h4>Interoperability</h4>
<p>One of our requirements for a new framework was that it should be easy to convert to and from the standard classes. Constructors in Joda-Time take <code>Date</code>, <code>Calendar</code>, <code>String</code>, and <code>long</code>. From <code>DateTime</code> we can easily get JDK <code>Date</code> and <code>Calendar</code>. The <code>DateTimeZone</code> class can be constructed from a <code>TimeZone</code> and also return a <code>TimeZone</code>. In the example below, we easily convert from a standard <code>Date</code> to Joda-Time's <code>DateTime</code> to a <code>GregorianCalendar</code>, and from the <code>DateTime</code> back to a <code>Date</code>:</p>
<pre class="java">&nbsp;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ADate+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Date</span></a> date = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ADate+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Date</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">106</span>, <span style="color: #cc66cc;">8</span>, <span style="color: #cc66cc;">19</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Sep 19, 2006</span>
DateTime dt = <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #66cc66;">&#40;</span>date<span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AGregorianCalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">GregorianCalendar</span></a> c = dt.<span style="color: #006600;">toGregorianCalendar</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ADate+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Date</span></a> d = dt.<span style="color: #006600;">toDate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<h4>Formatting</h4>
<p>What about formatting then? Compared to <code>SimpleDateFormat</code>, the <code>DateTimeFormatter</code> is fast, flexible, thread-safe, and immutable. Formatting can be done in several ways: using a pattern, a style, or a format builder. You can either pass a formatter to the <code>toString</code> method for <code>DateTime</code>, or you can ask the formatter to print the <code>DateTime</code>:</p>
<pre class="java">&nbsp;
DateTimeFormatter f = DateTimeFormat.<span style="color: #006600;">longDateTime</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
DateTime dateTime = <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>dateTime.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span>f<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>f.<span style="color: #006600;">print</span><span style="color: #66cc66;">&#40;</span>dateTime<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// May 25, 2006 9:45:09 PM CEST</span>
<span style="color: #808080; font-style: italic;">// May 25, 2006 9:45:09 PM CEST</span>
&nbsp;</pre>
<h4>DateTimeUtils</h4>
<p>If you need to stop time, or go back or forward in time, you can use the <code>DateTimeUtils</code> class. This code shows that it's possible to stop time:</p>
<pre class="java">&nbsp;
DateTime now = <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
DateTimeUtils.<span style="color: #006600;">setCurrentMillisFixed</span><span style="color: #66cc66;">&#40;</span>now.<span style="color: #006600;">getMillis</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// time has stopped!</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AThread+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Thread</span></a>.<span style="color: #006600;">sleep</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2000</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// 2006-05-25T23:21:37.562+02:00</span>
<span style="color: #808080; font-style: italic;">// 2006-05-25T23:21:37.562+02:00</span>
&nbsp;</pre>
<p>Turning back the clock is also possible:</p>
<pre class="java">&nbsp;
DateTime now = <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
Period period = Period.<span style="color: #006600;">months</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#41;</span>;
Duration dur = period.<span style="color: #006600;">toDurationFrom</span><span style="color: #66cc66;">&#40;</span>now<span style="color: #66cc66;">&#41;</span>;
DateTimeUtils.<span style="color: #006600;">setCurrentMillisOffset</span><span style="color: #66cc66;">&#40;</span>dur.<span style="color: #006600;">getMillis</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// we've gone back in time!</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// 2006-04-25T23:24:03.796+02:00</span>
&nbsp;</pre>
<p>Don't forget to reset to system time:</p>
<pre class="java">&nbsp;
DateTimeUtils.<span style="color: #006600;">setCurrentMillisSystem</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// we're back to normal</span>
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// 2006-05-25T23:29:41.281+02:00</span>
&nbsp;</pre>
<h3>Where were we?</h3>
<p>Oh, yes. Printing dates. Let's print out the same date using Joda-Time. It was 12.30 PM on July 2, 1945:</p>
<pre class="java">&nbsp;
DateTime date = <span style="color: #000000; font-weight: bold;">new</span> DateTime<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1945</span>, <span style="color: #cc66cc;">7</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">12</span>, <span style="color: #cc66cc;">30</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
DateTimeFormatter formatter = DateTimeFormat.<span style="color: #006600;">forPattern</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;yyyy-MM-dd HH:mm&quot;</span><span style="color: #66cc66;">&#41;</span>;
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>date.<span style="color: #006600;">toString</span><span style="color: #66cc66;">&#40;</span>formatter<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// 1945-07-02 12:30</span>
&nbsp;</pre>
<p>Couldn't be simpler.</p>
<h3>Conclusion</h3>
<p>The existing classes for date and time have drawbacks, some of them serious. The contender is Joda-Time, which is a complete rewrite and represents a mature API with a strong focus on usability, interoperability, stability and performance. What are you waiting for? Now is the time.</p>
<p>Update: <a href="http://tech.puredanger.com/java7/#jsr310">It seems</a> Java7 will be using JSR310, which basically is Joda-Time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2006/09/16/tired-of-date-and-calendar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

