• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Time Calculation according to the TimeZone

 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i have to calculate time according to the TimeZone. the thing is i am getting hour in not a railway time(example railway time means 1pm=13 hr,3pm=15,2AM=2 only ).. or else
---------------------------------------------
how can i know whether it is AM or PM
-----------------------------------------------




please anyone help me
 
Sheriff
Posts: 9709
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

If you want, you can get time in 24hr format by calling cal.get(Calendar.HOUR_OF_DAY)...as far as AM or PM is concerned...you can use cal.get(Calendar.AM_PM), it will return 0 if the time is AM and 1 if it is PM
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by seetharaman venkatasamy:
Hi,
i have to calculate time according to the TimeZone. the thing is i am getting hour in not a railway time(example railway time means 1pm=13 hr,3pm=15,2AM=2 only ).. or else
---------------------------------------------
how can i know whether it is AM or PM
-----------------------------------------------




please anyone help me




int i= cale.get(Calendar.AM_PM);
if it returns 0 means AM
if it returns 1 means PM
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks somuch Ankit Garg and Sanjeeva
 
Sheriff
Posts: 22854
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sanjeeva vem:



int i= cale.get(Calendar.AM_PM);
if it returns 0 means AM
if it returns 1 means PM


Actually it returns Calendar.AM and Calendar.PM. Those happen to be 0 and 1 respectively, but you should really compare them against these constants. Just like you need to compare weekdays against Calendar.SUNDAY until Calendar.SATURDAY, and months against Calendar.JANUARY until Calendar.DECEMBER. The latter is especially important because months are 0-based - month 1 is not January but February.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Rob prime
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic