IT認證考古題|IT認證題庫|IT認證考試信息 --Killtest考古題網

JAVA中UTC的使用

JAVA中UTC的使用

2011年3月8日 by admin

由於使用Date類型在數據庫搜索大量數據時效率很低,公司采取使用Long型timecode進行搜索: Calendar calendar=Calendar.getInstance(); Long timecode=calendar.getTimeInMillis(); 但是由於不同機器不同系統的時區設置不同,所以同壹時間產生的timecode的值也不同,導致搜索不到準確時間的數據的問題,所以采取如下方式進行解決: //將本地當前時間轉換成UTC國際標準時間的毫秒形式 Date time=new Date(); Long timecode=time.UTC(time.getYear(), time.getMonth(), time.getDate(), time.getHours(), time.getMinutes(), time.getSeconds()); //將UTC國際標準時間的毫秒形式轉換成本地的時間 Calendar calendar=Calendar.getInstance(); int offset=calendar.get(Calendar.ZONE_OFFSET); int dst=calendar.get(Calendar.DST_OFFSET); calendar.setTimeInMillis(timecode); calendar.add(Calendar.MILLISECOND, -(offset+dst)); Date resultDate=calendar.getTime();

Posted in: SUN Tagged: JAVA, UTC

分類

標籤

1z0-042 1Z0-851 1Z0-873 70-640 70-642 70-680 220-701 220-702 310-065 640-802 642-813 642-832 642-902 A+ Apple CCDA CCDP CCIE CCNA CCNP CCSP Cisco CIW COMPTIA DBA EMC EMC Certification HCSE HP IBM IBM Certification JAVA Java Standard Edition 6 Programmer Certified Professional Exam JN0-660 Linux LPI MCITP MCSE MCTS Microsoft Network+ Oracle SCJP Security+ SUN

Copyright © 2025 IT認證考古題|IT認證題庫|IT認證考試信息 --Killtest考古題網.

Custom WordPress Theme by themehall.com

  • Viasat Customer Agreement
  • Piercing Agreement Form
  • Isda Cds Agreement
  • Uk Egypt Association Agreement
  • Us New Zealand Trade Agreement
  • Simple Loan Contract between Family
  • What Is the Effect of Termination of a Contract
  • Lupc Framework Agreement
  • The Contractor Fight Reviews
  • Property Management Agreement in Kenya
  • Legal Definition Cancel a Contract
  • South Dakota Vehicle Purchase Agreement
  • Shared Equity Financing Agreement Pennsylvania
  • Sale Agreement Duration
  • Rental Agreement Registration Format
  • Quickpay Agreement Id
  • Investment Agreement Nigeria
  • Party Wall Agreement Details
  • 50 Shades of Grey Agreement Pdf
  • When Does a Cause of Action Accrue for Breach of Contract