Java

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Bean to Bean mapping

    1 answers - 1432 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Betwixt only converts value-for-value. If you need to break the date out
    like that then you need to create a new element bean:
    public class MyClass {
    private Date _myDate = new Date();
    public Date getMyDate() {
    return _myDate;
    }
    public DateBean getMyDateBean() {
    return new DateBean(_myDate);
    }
    }
    public class DateBean {
    private Calendar _calendar = Calendar.getInstance();
    public int getDay() {
    return _calendar.get(Calendar.DATE);
    }
    public int getMonth() {
    return _calendar.get(Calendar.MNTH + 1);
    }
    public int getYear() {
    return _calendar.get(Calendar.YEAR);
    }
    public DateBean(Date date) {
    _calendar.setTime(date);
    }
    }
    Then map that bean using a DateBean.betwixt file. You can also add setters
    for round-tripping.
    Hope that helps,
    Jesse
    Message
    From: Peter Konstantinov [mailto:pa (AT) iu6 (DOT) ru]
    Sent: Monday, 09, 2006 12:11 PM
    To: commons-user (AT) jakarta (DOT) apache.org
    Subject: [betwixt] Bean to Bean mapping
    Hi,
    How to convert java.util.Date to same xml:
    <date day="" month="" year="" />
    ConvertUStringConverter can convert only to String.
    Regards,
    Peter
    To unsubscribe, e-mail: commons-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: commons-user-help (AT) jakarta (DOT) apache.org
  • No.1 | | 1808 bytes | |

    Can you help to write DateBean.betwixt?

    Is it possible to do this without writing getMyDateBean method in all
    classes using Date?

    09.10.2006, at 21:21, Sweetland, Jesse wrote:

    Betwixt only converts value-for-value. If you need to break the
    date out
    like that then you need to create a new element bean:

    public class MyClass {
    private Date _myDate = new Date();

    public Date getMyDate() {
    return _myDate;
    }

    public DateBean getMyDateBean() {
    return new DateBean(_myDate);
    }
    }

    public class DateBean {
    private Calendar _calendar = Calendar.getInstance();

    public int getDay() {
    return _calendar.get(Calendar.DATE);
    }

    public int getMonth() {
    return _calendar.get(Calendar.MNTH + 1);
    }

    public int getYear() {
    return _calendar.get(Calendar.YEAR);
    }

    public DateBean(Date date) {
    _calendar.setTime(date);
    }
    }

    Then map that bean using a DateBean.betwixt file. You can also add
    setters
    for round-tripping.

    Hope that helps,

    Jesse

    Message
    From: Peter Konstantinov [mailto:pa (AT) iu6 (DOT) ru]
    Sent: Monday, 09, 2006 12:11 PM
    To: commons-user (AT) jakarta (DOT) apache.org
    Subject: [betwixt] Bean to Bean mapping

    Hi,
    How to convert java.util.Date to same xml:
    <date day="" month="" year="" />
    ConvertUStringConverter can convert only to String.

    Regards,
    Peter

    To unsubscribe, e-mail: commons-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: commons-user-help (AT) jakarta (DOT) apache.org

    To unsubscribe, e-mail: commons-user-unsubscribe (AT) jakarta (DOT) apache.org
    For additional commands, e-mail: commons-user-help (AT) jakarta (DOT) apache.org

Re: Bean to Bean mapping


max 4000 letters.
Your nickname that display:
In order to stop the spam: 6 + 6 =
QUESTION ON "Java"

EMSDN.COM