package org.wikidata.wdtk.datamodel.jsonconverter;

import java.math.BigDecimal;
import java.text.DecimalFormat;

import org.wikidata.wdtk.datamodel.interfaces.TimeValue;

public class DatatypeConverters {
	
	final static String FORMAT_YEAR = "00000000000";
	final static String FORMAT_OTHER = "00";

	/**
	 * Returns a representation of the date from the value attributes as ISO 8601 encoding.
	 * 
	 * @param year
	 * @param month
	 * @param day
	 * @param hour
	 * @param minute
	 * @param second
	 * @return ISO 8601 value (String)
	 * 
	 * @throws IllegalArgumentException
	 */
	public static String formatTimeISO8601(TimeValue value) throws IllegalArgumentException {
		StringBuilder builder = new StringBuilder();
		DecimalFormat yearForm = new DecimalFormat(FORMAT_YEAR);
		DecimalFormat timeForm = new DecimalFormat(FORMAT_OTHER);
		if (value.getYear() > 0) {
			builder.append("+");
		}
		builder.append(yearForm.format(value.getYear()));
		builder.append("-");
		builder.append(timeForm.format(value.getMonth()));
		builder.append("-");
		builder.append(timeForm.format(value.getDay()));
		builder.append("T");
		builder.append(timeForm.format(value.getHour()));
		builder.append(":");
		builder.append(timeForm.format(value.getMinute()));
		builder.append(":");
		builder.append(timeForm.format(value.getSecond()));
		builder.append("Z");
		return builder.toString();
	}

	/**
	 * Returns a String Representation of the given number attribute.
	 * 
	 * @param number
	 * @return String for BigDecimal value
	 */
	public static String formatBigDecimal(BigDecimal number) {
		if (number.signum() != -1) {
			return "+" + number.toString();
		}else{
			return number.toString();
		}
	}
	
}

@@ -165,16 +165,164 @@
 Value;%0A%0A
+/**%0A * This class contains static methods to create string notations for values of%0A * several data types and classes%0A * %0A * @author michael%0A * %0A */%0A
 public c
@@ -347,18 +347,17 @@
 rters %7B%0A
-%09
 %0A
+
 %09final s
@@ -515,24 +515,28 @@
 butes as ISO
+%0A%09 *
  8601 encodi
@@ -783,17 +783,20 @@
 e value)
- 
+%0A%09%09%09
 throws I
@@ -1804,12 +1804,14 @@
 %0A%09%09%7D
+ 
 else
+ 
 %7B%0A%09%09
@@ -1844,12 +1844,11 @@
 %0A%09%09%7D%0A%09%7D%0A
-%09
 %0A%7D%0A

Add javadoc for DatatypeConverters