com.javaetmoi.javabean.generator.SqlDateCodeGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javaetmoi-javabean-marshaller Show documentation
Show all versions of javaetmoi-javabean-marshaller Show documentation
The JavaBeanMarshaller class is responsible for serializing an object (graph) to it's Java code.
package com.javaetmoi.javabean.generator;
import com.javaetmoi.javabean.bean.SetterParam;
import com.javaetmoi.javabean.util.ParseDateMethod;
import com.squareup.javapoet.MethodSpec;
import java.sql.Date;
public class SqlDateCodeGenerator extends DefaultCodeGenerator {
@Override
public void generateSetter(MethodSpec.Builder method, SetterParam param) {
MethodSpec parseMethod = ParseDateMethod.requireParseDateMethod(param.getCurrentClass());
String strDate = ParseDateMethod.DATE_FORMAT.format(param.getValue());
method.addStatement("$L.$L(new java.sql.Date($N(\"" + strDate + "\").getTime()))", param.getVarName(), param.getSetterName(), parseMethod);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy