// Copyright 2001-2004, Danger, Inc. All Rights Reserved.
// This file is subject to the Danger, Inc. Sample Code License,
// which is provided in the file SAMPLE_CODE_LICENSE.
// Copies are also available from http://developer.danger.com/

package com.example.DataStoreDemo;

import danger.internal.Date;
import danger.text.Collator;

import danger.util.LocaleUtils;
import danger.util.format.DateFormat;

/**
 * This class encapsulates the version specific code necessary for maintaining
 * the 1.1 and 2.0 versions of the application.
 * 
 * These are utility routines, that perform the version specific tasks. The
 * routines are marked static so that they can be called without needing
 * instantiation.
 * 
 * This file is for the 2.0 variant of the code. These versions are preferable
 * because they provide for an internationalized end-user experience. These
 * versions were unavailable in the 1.1 version of the OS, but are required when
 * running under 2.0 or higher.
 */
public class Version {

	/**
	 * Compare the two strings passed in, in the best way possible for the
	 * version of the OS.
	 * 
	 * In this 2.0 variant, the string compare will use the Collator object in
	 * order to sort properly when using non-English languages. The 1.1 OS did
	 * not include the Collator.
	 * 
	 * Return less than 0, equal to 0, or greater than 0.
	 */
	public static int compareStrings(String name0, String name1) {
		Collator c = Collator.getInstance();

		return (c.compare(name0, name1));
	}

	/**
	 * Return the short style Date string for the passed in Date. For this 2.0
	 * variant, it is superior to use the DateFormat function to provide
	 * internationalization of the returned string.  It will use the current
	 * locale to format properly.
	 */
	public static String getDateString(Date date) {
		return (DateFormat.withFormat(LocaleUtils.getShortDateFormat(), date));
	}

}
