Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 90686 invoked from network); 3 Dec 2008 10:57:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Dec 2008 10:57:53 -0000 Received: (qmail 63001 invoked by uid 500); 3 Dec 2008 10:57:56 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 62978 invoked by uid 500); 3 Dec 2008 10:57:56 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 62967 invoked by uid 99); 3 Dec 2008 10:57:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Dec 2008 02:57:56 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of vlasevdr@gmail.com designates 72.14.220.155 as permitted sender) Received: from [72.14.220.155] (HELO fg-out-1718.google.com) (72.14.220.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Dec 2008 10:56:27 +0000 Received: by fg-out-1718.google.com with SMTP id l27so2532517fgb.9 for ; Wed, 03 Dec 2008 02:57:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=YGyKNqntxcw6LnzSGInjoTT+u9ImdlPL06Blx0wxbG4=; b=CLMhB1P6TTpzNfIU9bd2eaEPGWjjqDPaWMVN9FkIKstyuE/vBTFGMDrAThq9a3FUQh wiDIgyMbPLQ4ybw+vBeHUwvftGydOXiaHqOSjlPX0swbe1djcMilkENefanj8Mk8CKgW Dd5V88f2yr1DTky+wPtUHYHN39yUjFz5ZzeGY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=foffvdIw9ZTOCMCvG0E41VLUcU4rfXgaj0Pnd6Ip1ODh93BAdGy+WqGIry9HVmakJG mXPsUCHdGvAlIYkka16H+WvCOcJWmkFkYOFrG2sc6h+ashsTssRUldz5ktReC2VhjDeb uiUGT6CiqUAy5limkf5yRio62WI+gSc/RPOzY= Received: by 10.86.31.18 with SMTP id e18mr7869580fge.72.1228301823980; Wed, 03 Dec 2008 02:57:03 -0800 (PST) Received: by 10.86.57.16 with HTTP; Wed, 3 Dec 2008 02:57:03 -0800 (PST) Message-ID: <8e161b980812030257r5b712e44ge66ae737b381e01c@mail.gmail.com> Date: Wed, 3 Dec 2008 12:57:03 +0200 From: "Dimitar Vlasev" To: "Struts Users Mailing List" Subject: Re: Dojo datetimepicker problem In-Reply-To: <8e161b980812030053k5a9636eag39e5bfa84c16f431@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <8e161b980812020810g1accec0ep5eec85769d7c9fde@mail.gmail.com> <4935A69A.90005@genome.med.harvard.edu> <8e161b980812030053k5a9636eag39e5bfa84c16f431@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Few findings: http://struts.apache.org/2.0.14/docs/type-conversion.html at section "Built in Type Conversion Support" documentation says: XWork will automatically handle the most common type conversion for you. This includes support for converting to and from Strings for each of the following: ......... -> dates - uses the SHORT format for the Locale associated with the current request ......... But I haven't tried yet to utilize this feature. This is what worked for me: What I've done was to create custom type conversion class ------------------------------- public class ShortDateConverter extends StrutsTypeConverter { public final static String pattern = "dd.MM.yyyy"; private final static SimpleDateFormat format = new SimpleDateFormat(pattern); public Object convertFromString(Map context, String[] values, Class toClass) { Date result = null; if (values != null && values.length > 0) { try { result = format.parse(values[0]); } catch (ParseException e) { throw new TypeConversionException("Error converting date from '" + values[0] + "', pattern: '" + pattern + "'"); } } return result; } public String convertToString(Map context, Object o) { return null; } } and applied it to the setter method within my action class: (it worked well both using annotation and -conversion.properties file) ----------------- @TypeConversion (type=ConversionType.CLASS, converter="test.ShortDateConverter") public void setADate(Date date) { ............... Though it would be even elegant enough solution if I was able to refer to the static pattern String in the .jsp like that But I got exception: According to TLD or attribute directive in tag file, attribute displayFormat does not accept any expressions I hope these findings will help someone else. Regards, Dimitar Vlasev --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org