• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to extract zone from a date which has it.

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a date in this format ->SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm Z");

How can i extract just Z ie. Zone from it, is it possible with stringifying and extracting it.
 
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't really understand your requirement. java.util.Date objects do not have an explicit time zone (the implicit one is UTC) so it seems you must be considering the date as a String. If one uses class SimpleDateFormat to parse this to a java.util.Date then one loses any time zone information that was explicit in the String so I suspect one has to parse the String oneself to extract the time zone. I would use a regular expression but they are not to everyone's taste.

Once you have the time zone extracted as a String then one can convert it to a TimeZone object using one of the static methods of class TimeZone.
 
Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic