package gov.nih.nci.cabig.caaers.domain;

import javax.persistence.Embeddable;
import javax.persistence.Transient;

@Embeddable
public class TimeValue {

    private Integer hour;
    private Integer minute;
    private int type = 0; // this is to force hibernate to instantiate it.


    public Integer getHour() {
        return hour;
    }


    public void setHour(Integer hour) {
        this.hour = hour;
    }


    public Integer getMinute() {
        return minute;
    }


    public void setMinute(Integer minute) {
        this.minute = minute;
    }


    public void setType(int type) {
        this.type = type;
    }

    public int getType() {
        return type;
    }
    
    @Transient
    public String getMinuteString(){
    	if(minute == null) return null;
    	return String.format("%02d", minute);
    }
    public void setMinuteString(String min){
    	if(min == null || min.length() < 0) minute = null;
    	minute = Integer.valueOf(min);
    }
    @Transient
    public String getHourString(){
    	if(hour == null) return null;
    	return String.format("%02d", hour);
    }
    public void setHourString(String hr){
    	if(hr == null || hr.length() < 0) hour = null;
    	hour = Integer.valueOf(hr);
    }
    @Transient
    public boolean isAM() {
        return type == 0;
    }

    @Transient
    public boolean isPM() {
        return type == 1;
    }

    @Override
    public String toString() {
        return String.format("%02d:%02d %s", hour, minute, (type == 1 ? "PM" : "AM"));
    }


}

@@ -109,16 +109,62 @@
 sient;%0A%0A
+import org.apache.commons.lang.StringUtils;%0A%0A%0A
 @Embedda
@@ -924,72 +924,48 @@
    %09
-if(min == null %7C%7C min.length() %3C 0) minute = null;%0A    %09minute =
+minute = StringUtils.isBlank(min)? null:
  Int
@@ -1172,66 +1172,47 @@
    %09
-if(hr == null %7C%7C hr.length() %3C 0) hour = null;%0A    %09hour =
+hour = StringUtils.isBlank(hr) ? null :
  Int

Fix for number format error