Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / June 2005

Tip: Looking for answers? Try searching our database.

Finding time

Thread view: 
Oxnard - 19 Jun 2005 18:24 GMT
I have the number of micro seconds from the UNIX epoch time 00:00:00 UTC 1
Jan 1970.  (1092727073895638 usec)
I want to know the time in CST.

I have been trying to work with the Calendar class and GregorianCalendar.
But I am not quite getting it. Could someone give me an idea of what I need
to do.

Thanks
Ox
Andrew Thompson - 19 Jun 2005 18:51 GMT
> I have the number of micro seconds from the UNIX epoch time 00:00:00 UTC 1
> Jan 1970.  (1092727073895638 usec)
> I want to know the time in CST.

What does the 'C' stand for?  Central or China (or..)?

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Remi Arntzen - 20 Jun 2005 01:39 GMT
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html#setTime(java.uti
l.Date
)
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html#setTimeZone(java
.util.TimeZone
)
You shouldn't use CST becuase it can mean either "Central Standard
Time" or "China Standard Time"
RC - 21 Jun 2005 22:12 GMT
> I have the number of micro seconds from the UNIX epoch time 00:00:00 UTC 1
> Jan 1970.  (1092727073895638 usec)
[quoted text clipped - 3 lines]
> But I am not quite getting it. Could someone give me an idea of what I need
> to do.

Calendar cal = Calendar.getInstance(
                    TimeZone.getTimeZone("GMT"), // +00:00
                    Locale.getDefault());

 cal.setTime(new Date((long)1092727073895638));

 public String printDate(Calendar cal) {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    sdf.setTimeZone(TimeZone.getTimeZone("CST")); // -06:00
  // what happen when change to CDT (Central Daylight Time, -05:00) ?
    return(sdf.format(cal.getTime()));
    }

BTW (By the way) China is CCT (China Coastal Time) +08:00, not CST.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.