Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Date Format with jax-rs in apache cxf?

Tags:

jax-rs

cxf

I have been googling to figure out how I can customize the Date format when I use jax-rs on apache CXF. I looked at the codes, and it seems that it only support primitives, enum and a special hack that assume the type associated with @FormParam has a constructor with a single string parameter. This force me to use String instead of Date if I want to use FormParam. it is kind of ugly. Is there a better way to do it?

@POST
@Path("/xxx")
public String addPackage(@FormParam("startDate") Date startDate)
    {
      ...
    } 

Thanks

like image 454
Oscar Chan Avatar asked Feb 27 '23 00:02

Oscar Chan


1 Answers

starting from CXF 2.3.2 registering ParameterHandler will do it. It is also always possible to override the date value (passed as part of the query, etc) using RequestHandler filters for default Date(String) to work

like image 61
Sergey Beryozkin Avatar answered Apr 27 '23 08:04

Sergey Beryozkin