Try something like this for your dates

package edu.darden.common.tapestry;

import edu.darden.common.codetables.ivalue.ViewingRolesData;
import edu.darden.common.config.ApplicationProperties;
import edu.darden.common.tapestry.link.DardenCallback;
import edu.darden.common.tapestry.link.PreviousPage;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.callback.ICallback;

import java.io.Serializable;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Iterator;
import java.util.LinkedList;

public class Visit implements Serializable, DardenCallback, PreviousPage
{
    private boolean debug = false;
    Log LOG = LogFactory.getLog(Visit.class);

    private ICallback callback = null;

    private static final SimpleDateFormat DATE_FORMAT = new
SimpleDateFormat("dd MMM yyyy");
    private static final SimpleDateFormat MONTH_YEAR_FORMAT = new
SimpleDateFormat("MMM yyyy");
    private static final SimpleDateFormat DAY_OF_THE_WEEK_DATE_FORMAT =
new SimpleDateFormat("EEEE, MMMM d, yyyy");
    private static final SimpleDateFormat TRADITIONAL_DATE_FORMAT = new
SimpleDateFormat("MMMM d, yyyy");
    private static final SimpleDateFormat SHORT_DATE_FORMAT = new
SimpleDateFormat("M/dd/yy");
    private static final SimpleDateFormat SHORT_FOUR_YEAR_DATE_FORMAT =
new SimpleDateFormat("M/dd/yyyy");
    private static final SimpleDateFormat SHORT_MONTH_YEAR_FORMAT = new
SimpleDateFormat("M/yy");
        private static final SimpleDateFormat TIME_FORMAT = new
SimpleDateFormat("h:mm a");
        private static final SimpleDateFormat MILITARY_TIME_FORMAT = new
SimpleDateFormat("H:mm");
    private static final SimpleDateFormat DATETIME_FORMAT = new
SimpleDateFormat("dd MMM yyyy hh:mm a");
    private static final SimpleDateFormat TRADITIONAL_DATETIME_FORMAT =
new SimpleDateFormat("MMMM d, yyyy h:mm a");
    private static final SimpleDateFormat LONG_DATETIME_FORMAT = new
SimpleDateFormat("EEEE, MMMM d, yyyy h:mm a");
    private static final SimpleDateFormat LONG_TIMEDATE_FORMAT = new
SimpleDateFormat("h:mm a EEEE, MMMM d, yyyy");
    private static final SimpleDateFormat SHORT_DATETIME_FORMAT = new
SimpleDateFormat("MM/dd/yy h:mm a");
    private static final SimpleDateFormat DEADLINE_DATETIME_FORMAT = new
SimpleDateFormat("EEEE, MMMM d, yyyy @ h:mm a");

    private SimpleDateFormat timeRangeFormat;
    private String timeRangeFormatString;

        private int selectedSubmenuIndex;
        private int selectedMenuIndex;
        private String[] lastTwoURLS = new String[2];
    //bread crumbs is the trail of pages visited
    private LinkedList breadCrumbs;
    private static final int MAX_BREADCRUMBS = 3;//TODO use more if we
implement bread crumbs links

    //Viewing Roles info.
    private ViewingRolesData[] viewingRoles = null;
    private boolean userHasReadRules = true;
    // needed only for Career
    private boolean userNeedsToUpdateJobSeekingQuestion = false;

    /**
     * Ensure that the user data has been loaded for
     * @param cycle
     */
    public void ensureUserLoaded(IRequestCycle cycle){
        //empty, but can be overloaded by subclasses
    }


    public String getUsername(IRequestCycle cycle) {
        return CommonLoginUtils.getUserName(cycle);
    }

    public void toggleDebug() {
        debug = !debug;
    }

    public boolean isDebug() {
        return debug;
    }

    public Format getDateFormat(){
        return DATE_FORMAT;
    }

    public Format getMonthYearFormat(){
        return MONTH_YEAR_FORMAT;
    }

    public Format getDayOfTheWeekDateFormat(){
        return DAY_OF_THE_WEEK_DATE_FORMAT;
    }

    public Format getTraditionalDateFormat(){
        return TRADITIONAL_DATE_FORMAT;
    }

    public Format getShortFourYearDateFormat(){
            return SHORT_FOUR_YEAR_DATE_FORMAT;
    }

    public Format getShortDateFormat(){
            return SHORT_DATE_FORMAT;
    }

    public Format getShortMonthYearFormat(){
            return SHORT_MONTH_YEAR_FORMAT;
    }

        public Format getTimeFormat(){
                return TIME_FORMAT;
        }

        public Format getMilitaryTimeFormat(){
                return MILITARY_TIME_FORMAT;
        }

    public Format getDatetimeFormat() {
        return DATETIME_FORMAT;
    }

    public Format getTraditionalDatetimeFormat() {
        return TRADITIONAL_DATETIME_FORMAT;
    }

    public Format getLongDatetimeFormat() {
        return LONG_DATETIME_FORMAT;
    }

    public Format getLongTimedateFormat() {
        return LONG_TIMEDATE_FORMAT;
    }

    public Format getShortDatetimeFormat(){
            return SHORT_DATETIME_FORMAT;
        }

    public Format getDeadlineDatetimeFormat() {
        return DEADLINE_DATETIME_FORMAT;
    }

        public int getSelectedMenuIndex() {
                return selectedMenuIndex;
        }

        public int getSelectedSubmenuIndex() {
                return selectedSubmenuIndex;
        }

        public void setSelectedMenuIndex(int i) {
                selectedMenuIndex = i;
        }

        public void setSelectedSubmenuIndex(int i) {
                selectedSubmenuIndex = i;
        }

    public ICallback getCallback() {
        return callback;
    }

    public void setCallback(ICallback callback) {
        this.callback = callback;
    }

    public String[] getLastTwoURLs(){
        return this.lastTwoURLS;
    }

    public void setLastTwoURLs(String[] lastTwoURLs){
        this.lastTwoURLS = lastTwoURLs;
    }

    public void clearBreadCrumbs(){
        breadCrumbs = null;
    }

    public void pushBreadCrumb(ICallback callback) {
        //LinkedList breadCrumbs = getBreadCrumbs();
        if(breadCrumbs == null) {
            breadCrumbs = new LinkedList();
        } else if(breadCrumbs.size() > MAX_BREADCRUMBS){
            breadCrumbs.removeFirst();
        }

        if(breadCrumbs.size() > 0){
            String previousPage =
((ICallback)breadCrumbs.getLast()).toString();
            if(callback.toString().equalsIgnoreCase(previousPage))
return;
        }

//        LOG.info("-----------breadCrumb added: " +
callback.toString());
        breadCrumbs.addLast(callback);
    }

    public Iterator getBreadCrumbsIterator() {
        if(breadCrumbs == null) return new LinkedList().iterator();
        return breadCrumbs.iterator();
    }

    public ICallback getPreviousPage() {
//        Iterator iter = getBreadCrumbsIterator();
//        LOG.info("---------(getting previous page) breadCrumbs:\n");
//        while (iter.hasNext()) {
//            ICallback callback = (ICallback) iter.next();
//            LOG.info(callback.toString());
//        }

        if(breadCrumbs == null || breadCrumbs.size() < 2) return null;
        ICallback callback =
(ICallback)breadCrumbs.get(breadCrumbs.size()-2);
//        LOG.info("-------- returning callback: " +
callback.toString());
        return callback;
    }

    public Format getTimeRangeFormat(){
        String formatString =
ApplicationProperties.getStringProperty("timeRangeFormat");

        if(timeRangeFormat == null ||
!formatString.equals(timeRangeFormatString)){
            timeRangeFormat = new SimpleDateFormat(formatString);
        }
        return timeRangeFormat;
    }

    public ViewingRolesData[] getViewingRoles() {
        return viewingRoles;
    }

    public void setViewingRoles(ViewingRolesData[] viewingRoles) {
        this.viewingRoles = viewingRoles;
    }

    public boolean isUserHasReadRules() {
        return userHasReadRules;
    }
    public void setUserHasReadRules(boolean userHasReadRules) {
        this.userHasReadRules = userHasReadRules;
    }


    public boolean isUserNeedsToUpdateJobSeekingQuestion() {
        return userNeedsToUpdateJobSeekingQuestion;
    }


    public void setUserNeedsToUpdateJobSeekingQuestion(
            boolean userNeedsToUpdateJobSeekingQuestion) {
        this.userNeedsToUpdateJobSeekingQuestion =
userNeedsToUpdateJobSeekingQuestion;
    }

}

-----Original Message-----
From: Peter Dawn [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 13, 2006 6:06 PM
To: tapestry-user@jakarta.apache.org
Subject: Date formats

guys,

i am working on a tap3 web app. i want to implement a drop down menu
with various date formats (like DDMMYYYY etc.). the user selects one,
clicks on submit and the system uses this date format everytime now.

i am currently working on the drop down page. can somebody help me out
with the logic behind taking the entry and formatting the dates
accordingly. thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to