org.riverframework.utils
Class Converter

java.lang.Object
  extended by org.riverframework.utils.Converter

public class Converter
extends Object

Provides converters from any type to String, Integer, Double and Date. If the converter can not make the conversion it returns "", 0, 0, and null, respectively. This class is useful in org.riverframework.wrapper.* because makes simple to recover data in Java format.

Author:
mario.sotil@gmail.com

Constructor Summary
Converter()
           
 
Method Summary
static Date getAsDate(Object value)
          Converts the value parameter to a Date.
static Double getAsDouble(Object value)
          Converts the value parameter to a Double.
static Integer getAsInteger(Object value)
          Converts the value parameter to an Integer.
static Long getAsLong(Object value)
          Converts the value parameter to a Long.
static String getAsString(Object value)
          Converts the value parameter to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Converter

public Converter()
Method Detail

getAsString

public static String getAsString(Object value)
Converts the value parameter to a String. If the value is null, it returns an empty string. If the parameter is a Date object, it will be converted to the ISO 8601 format: yyyy-MM-ddTHH:mm:ss.SSSZ

Parameters:
value - It could be any object.
Returns:
a String

getAsInteger

public static Integer getAsInteger(Object value)
Converts the value parameter to an Integer. If the value is null or invalid, it returns zero.

Parameters:
value - Accepts String or any Number
Returns:
an Integer

getAsLong

public static Long getAsLong(Object value)
Converts the value parameter to a Long. If the value is null or invalid, it returns zero.

Parameters:
value - Accepts String or any Number
Returns:
a Long

getAsDouble

public static Double getAsDouble(Object value)
Converts the value parameter to a Double. If the value is null or invalid, it returns zero.

Parameters:
value - Accepts String or any Number
Returns:
a Double

getAsDate

public static Date getAsDate(Object value)
Converts the value parameter to a Date. If the value is null or invalid, it returns null. If the value is a String, it has to have one of the following syntax:

If the value is a Long number, it has to have the time in milliseconds.

Parameters:
value - Accepts String, Long and Date
Returns:
an Integer


Copyright © 2015. All rights reserved.