Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7542827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:16:17+00:00 2026-05-30T08:16:17+00:00

I have a custom converter like this: @Override public Object getAsObject(FacesContext facesContext, UIComponent component,

  • 0

I have a custom converter like this:

@Override
public Object getAsObject(FacesContext facesContext, UIComponent component, String str) {
    System.out.println("vadeConverter before getAsObject(" + str);
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");

    String values[] = str.split(":");
    Vade vade = new Vade();
    if (values.length > 1) {
        vade.setId(Integer.parseInt(values[0]));
        vade.setEtiket(values[1]);
        try{
            vade.setTakasTarihi(dateFormat.parse(values[2]));
        }catch (Exception e){
            e.printStackTrace();
        }           
    }
    System.out.println("vadeConverter after getAsObject(" + vade.toString());
    return vade;
}

@Override
public String getAsString(FacesContext context, UIComponent component,
        Object object) {
    Vade vade = (Vade) object;
    String str = "";
    System.out.println("vadeConverter before getAsString(object) -> " + vade.toString());
    if (vade != null) {
        str = vade.getId().toString()+":"+
                vade.getEtiket()+":"+
                vade.getTakasTarihi().toString()
                ;
    }
    System.out.println("vadeConverter after getAsString(object) -> " + str);
    return str;
}

In the output in the console is:

vadeConverter before getAsString(object) -> Vade{id=7etiket=T+0takasTarihi=2012-02-21}
vadeConverter after getAsString(object) -> 7:T+0:2012-02-21
vadeConverter before getAsString(object) -> Vade{id=12etiket=T+2takasTarihi=2012-02-27}
vadeConverter after getAsString(object) -> 12:T+2:2012-02-27
vadeConverter before getAsString(object) -> Vade{id=13etiket=T+3takasTarihi=2012-02-28}
vadeConverter after getAsString(object) -> 13:T+3:2012-02-28
vadeConverter before getAsString(object) -> Vade{id=14etiket=T+4takasTarihi=2012-02-29}
vadeConverter after getAsString(object) -> 14:T+4:2012-02-29
vadeConverter before getAsString(object) -> Vade{id=15etiket=T+5takasTarihi=2012-03-01}
vadeConverter after getAsString(object) -> 15:T+5:2012-03-01
vadeConverter before getAsString(object) -> Vade{id=16etiket=T+6takasTarihi=2012-03-02}
vadeConverter after getAsString(object) -> 16:T+6:2012-03-02
vadeConverter before getAsString(object) -> Vade{id=17etiket=T+7takasTarihi=2012-03-03}
vadeConverter after getAsString(object) -> 17:T+7:2012-03-03
vadeConverter before getAsString(object) -> Vade{id=18etiket=T+8takasTarihi=2012-03-04}
vadeConverter after getAsString(object) -> 18:T+8:2012-03-04
vadeConverter before getAsString(object) -> Vade{id=19etiket=T+9takasTarihi=2012-03-05}
vadeConverter after getAsString(object) -> 19:T+9:2012-03-05

when I select a value from the selectonemenu in the console I get this:

vadeConverter before getAsObject(12:T+2:2012-02-27
vadeConverter after getAsObject(Vade{id=12etiket=T+2takasTarihi=Fri Jan 27 00:02:00 EET 2012}

and of course as a result I get validation error. I believe I write the converter in right way, but I don’t know what is wrong with this code..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:16:18+00:00Added an answer on May 30, 2026 at 8:16 am

    You’re using mm instead of MM to denote months. The mm stands for minutes. Note that you’re getting Jan instead of Feb and that you get 2 minutes instead of 0 minutes. You can find the formatting pattern syntax in SimpleDateFormat javadoc.

    More reliable would however be to use getTime() and new Date(time) instead of toString() and SimpleDateFormat#parse(). This way you’re also not dependent on the default toString() result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object like this: class MyObject { public string Object.Prop1 { get;
I have a custom converter which is this : @ManagedBean @RequestScoped public class MeasureConverter
Let's say I have a custom class like this one: public class Customer {
hi i would like to create a custom calendar, this calendar will have custom
I have a command object: public class Job { private String jobType; private String
I have a string of XML that looks like this: <e1 atr1=3 atr2=asdf> <e1b
I have a custom c# type like (just an example): public class MyVector {
I have an array of custom objects. MyCustomArr[]. I want to convert this to
I have an event listener for a custom event type. This custom event overrides
My Grails application has a large number of enums that look like this: public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.