Suppress TimeZone info of a Java Calendar object

 
PHP Freelancer

Overview

To objective is to tell the Calendar object not to show timezone info (i.e. Show ‘2011-03-24′ instead of ‘2011-03-24+08:00′) when printing out date. One of the example is when using with XMLBeans.

Reference

suppressing time zone when printing an xsd:date : Weblogic

Calendar (Java 2 Platform SE v1.4.2) – clear(int)

Steps

The key is the Calendar.clear(int) function. We can use it to tell the Calendar object that time zone info is not set, thus the info will not be printed out.

Calendar calNoTz = Calendar.getInstance();
calNoTz.clear(Calendar.ZONE_OFFSET); // Clear the 'Zone offset' info
 

Discussion

What do you think? Leave a comment. Alternatively, write a post on your own weblog; this blog accepts trackbacks [trackback url].

Comments
1.
On March 28th, 2012 at 5:28 am, The most successful workflow engines Base said:
Hi there i am kavin, its my first occasion to commenting anywhere, when i read this piece of writing i thought i could also create comment due to this brilliant post.
Mentions on other sites...
  1. OMGPOP Draws Zynga?s Daily User Traffic Up By 25% | Hip Hop News Today on April 2nd, 2012 at 9:30 am:
Leave a Reply