package org.dspace.app.xmlui.aspect.general;

import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.acting.AbstractConfigurableAction;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Response;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.lang.time.FastDateFormat;
import org.dspace.app.xmlui.utils.HandleUtil;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;

import java.util.*;

/**
 * User: lantian @ atmire . com
 * Date: 11/13/13
 * Time: 5:30 PM
 */
public class LastModifiedDate extends AbstractConfigurableAction implements ThreadSafe {

        private FastDateFormat formatter = null;
        int days = 0;
        int hours = 0;
        int minutes = 0;
        int seconds = 0;

        public void configure(Configuration configuration)
                throws ConfigurationException {
            super.configure(configuration);
        }

        public Map act(Redirector redirector, SourceResolver resolver,
                       Map objectModel, String source, Parameters parameters)
                throws Exception {
            Response response = ObjectModelHelper.getResponse(objectModel);

            DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
            Map values = new HashMap(3);
            Date date = new Date();
            String value = date.toString();

            if(dso instanceof Item)
            {
                Item item = (Item) dso;
                Date lastModified = item.getLastModified();
                /* Get the current time and output as the last modified header */
                value =  lastModified.toString();
            }
            response.setHeader("Last-Modified", value);
            values.put("last-modified",  value);

            /* Return the headers */
            return(Collections.unmodifiableMap(values));

        }
    }


@@ -1252,16 +1252,484 @@
 ration);
+%0A%0A            // RFC-822 Date with a GMT based time zone%0A            this.formatter = FastDateFormat.getInstance(%22EEE, dd MMM yyyy kk:mm:ss zzz%22);%0A            this.days = configuration.getChild(%22days%22).getValueAsInteger(0);%0A            this.hours = configuration.getChild(%22hours%22).getValueAsInteger(0);%0A            this.minutes = configuration.getChild(%22minutes%22).getValueAsInteger(0);%0A            this.seconds = configuration.getChild(%22seconds%22).getValueAsInteger(0);
 %0A       
@@ -1992,17 +1992,95 @@
 Model);%0A
+            Calendar calendar = Calendar.getInstance(DateUtils.UTC_TIME_ZONE);
 %0A
-
         
@@ -2197,73 +2197,53 @@
     
-Date date = new Date();%0A            String value = date.toString(
+String value = this.formatter.format(calendar
 );%0A%0A

Remove unneeded changes to date formating