Java SQL Date canConvert(Class clz)

Here you can find the source of canConvert(Class clz)

Description

Returns true if the given class can be converted.

License

Apache License

Parameter

Parameter Description

Return

boolean

Declaration

public static boolean canConvert(Class<?> clz) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;

public class Main {
    @SuppressWarnings("serial")
    private static final List<Class<?>> TRANSFERABLES = new ArrayList<Class<?>>() {
        {/* w  w  w  .  j a v  a 2s .  c o  m*/
            add(Date.class);
            add(java.sql.Date.class);
            add(DateTime.class);
            add(LocalDate.class);
            add(BigDecimal.class);
            add(SimpleDateFormat.class);
        }
    };

    /**
     * Returns true if the given class can be converted.
     * The following classes are supported: 
     * java.util.Date, org.joda.time.DateTime, org.joda.time.LocalDate, BigDecimal
     * @param clz, Class<?>
     * @return boolean
     */
    public static boolean canConvert(Class<?> clz) {
        return TRANSFERABLES.contains(clz);
    }
}

Related

  1. calcLastMonth(String begin, String end, String now, GregorianCalendar calendar)
  2. calcThisMonth(String begin, String end, String now, GregorianCalendar calendar)
  3. convert(Class propertyType, Object value, String propertyName)
  4. convert(Object o)
  5. convertTo(Class clazz, Object obj)
  6. convertTo(final Class> clazz, Object obj)