Milton.io | Date conversions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Milton.io | Date conversions

Semburakkiannan, Raghunathan (IT Consultant)

Hello – I’m try to use the following method for setting the Date attributes for the files.

 

    @CreatedDate

    public java.util.Date getCreatedDate(Entity entity) {

 

   }

 

Is there a way for me to enforce the return date always to one particular time zone(say Eastern Timezone) even though my server might be in other time zone?

 

Thanks

 

 


_______________________________________________
Milton-users mailing list
[hidden email]
http://lists.justthe.net/mailman/listinfo/milton-users
Reply | Threaded
Open this post in threaded view
|

Re: Milton.io | Date conversions

bradmacnz
A Date represents an instant in time, and is represented as a number of milliseconds since a fixed date. So timezones arent relevant to Date, only to the formatting of the date into text.

The formatting of dates into header strings is handled in AbstractResponse:

    protected void setAnyDateHeader(Header name, Date date) {
        if (date == null) {
            return;
        }
        String fmt = DateUtils.formatForHeader(date);
        setResponseHeader(name, fmt);

    }

.. and DateUtils

    public static String formatForHeader(Date date) {
        DateFormat df = thHeaderDateFormat.get();
        if (df == null) {
            df = new SimpleDateFormat(DateUtils.PATTERN_RESPONSE_HEADER);
            df.setTimeZone(TimeZone.getTimeZone("GMT"));
            thHeaderDateFormat.set(df);
        }
        return df.format(date);
    }

As you can see the timezone is set as GMT when formatting the  date for output, which you should probably stick with unless there is a compelling reason to do otherwise.

On 24/05/16 09:08, Semburakkiannan, Raghunathan (IT Consultant) wrote:

Hello – I’m try to use the following method for setting the Date attributes for the files.

 

    @CreatedDate

    public java.util.Date getCreatedDate(Entity entity) {

 

   }

 

Is there a way for me to enforce the return date always to one particular time zone(say Eastern Timezone) even though my server might be in other time zone?

 

Thanks

 

 



_______________________________________________
Milton-users mailing list
[hidden email]
http://lists.justthe.net/mailman/listinfo/milton-users


_______________________________________________
Milton-users mailing list
[hidden email]
http://lists.justthe.net/mailman/listinfo/milton-users