`
tanglei198577
  • 浏览: 60002 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类

The usage of time and date

    博客分类:
  • java
阅读更多

There are some usage of time we often used for developping,here is my submit:

 

one:

    Get the unique value by getTime

   

    import java.sql.Timestamp;

    import java.util.Date;

       Date date=new Date();

       Timestamp st=new Timestamp(date.getTime());

       String uniqueStr="U";

       uniqueStr=uniqueStr+st.getTime(); //the sum of microsecond from 1970

 

two :

    The transition of Date and String()

   

public class StringToDate {

    public static Date stringToDate(String dateString){

      Date date;

       try {

           date = new SimpleDateFormat("yyyy-MM-dd").parse(dateString);

           return date;

       } catch (ParseException e) {

           // TODO Auto-generated catch block

           e.printStackTrace();

           return null;

       }

    }

 Three, when we want to calculate the time of execution of our program:

long startTime = System.currentTimeMillis();
long endTime = System.currentTimeMillis();
System.out.println("The time used is "+(endTime-startTime)+" ms");

 

If you have some good methods of time ,pls share it!

分享到:
评论

相关推荐

    The Art of Assembly Language Programming

    You are visitor as of October 17, 1996. The Art of Assembly Language Programming <br>Forward Why Would Anyone Learn This Stuff? 1 What's Wrong With Assembly Language 2 What's Right With ...

    Cheat engine help manual

    This help file is intended to familiarize you with the basic features and usage of Cheat Engine. Some examples for various things are given, but a lot of the actual 'gamehacking' is out of the scope ...

    基于ssm+mysql羽毛球馆管理系统源码数据库论文.doc

    However, this abundance of resources inevitably leads to conflicts in usage and waste, particularly in the case of badminton resources that this study focuses on. To address this issue, I propose ...

    Firefox and Thunderbird Garage

    According to spreadfirefox.com, to-date there have been ~ 23 million downloads since the release of Firefox 1.0 in September 2004, and MS IE usage has been dropping at the same time. Thunderbird has ...

    polycom宝利通视频会议软件3.9 2018

    “SUBSCRIPTION PERIOD” means the period of time you have licensed the SOFTWARE PRODUCT, beginning upon LICENSE ACTIVATION and ending after the duration listed in your AUTHORIZED PURCHASE ORDER. ...

    Ubuntu The Complete Reference

    - **Basic System Settings**: Discussion of configuring basic settings such as date and time, regional settings, and power management. - **Advanced System Configuration**: In-depth coverage of more ...

    Ruby Pocket Reference

    The book covers the syntax and usage of `sprintf` and the time formatting options. - **Interactive Ruby (irb) and the Ruby Debugger:** irb is an interactive shell for experimenting with Ruby code. ...

    二级减速器课程设计说明书reducer design specification.doc

    According to the selected fullload speed of the motor nm and the drive shaft speed of the motor nw,we can calculate the total transmission ratio of the transmission device ia: (2)Allocate ...

    2009 达内Unix学习笔记

    ls -t (time)按修改时间排序,显示目录和文件。 ls -lt 是“-l”和“-t”的组合,按时间顺序显示列表。 ls -F 显示文件类型,目录“/ ”结尾;可执行文件“*”结尾;文本文件(none),没有结尾。 ls -R 递归显示...

    spssw-184.zip

    Although myths and speculation about a Terra Australis (Southern Land) date back to antiquity, the first confirmed sighting of the continent is commonly accepted to have occurred in 1820 by the ...

    智慧教室电气与环境监测模块开发.doc

    The BL0940 electric parameter monitoring module plays a crucial role in capturing real-time data about the electrical conditions in the classroom, allowing for efficient energy management and ...

    OpenGL SuperBible 5th Edition.pdf

    Readers will find up-to-date, hands-on guidance on all facets of modern OpenGL development, including transformations, texture mapping, shaders, advanced buffers, geometry management, and much more....

    Android代码-时间选择器,选择特定间隔时间段。

    And note that, it utilizes Joda-Time to process some date time logic under the hood. So you might need to set up Joda-Time properly. With start and end date times specified: val intent = ...

    微软内部资料-SQL性能优化3

    In our example, if one transaction (T1) holds an exclusive lock at the table level, and another transaction (T2) holds an exclusive lock at the row level, each of the transactions believe they have ...

    More.Math.Into.LaTeX.3319237950

    In this carefully revised fifth edition, the Short Course has been brought up to date and reflects a modern and practical approach to LaTeX usage. New chapters have been added on illustrations and how...

    jdk1.8_win64.rar

    4. **Date and Time API**: Java 8 overhauls the date and time handling with the introduction of the `java.time` package, replacing the older `java.util.Date` and `java.util.Calendar`. The new API is ...

    Android代码-ThreeTenABP

    ThreeTen Android Backport ...for the ailing Date and Calendar APIs in both Java and Android. JSR-310 was backported to Java 6 by its creator, Stephen Colebourne, from which this library i

    Packt.Python.Journey.from.Novice.to.Expert.2016

    Learn the trickier aspects of Python and put it in a structured context for deeper understanding of the language Who This Book Is For This course is meant for programmers who wants to learn Python ...

Global site tag (gtag.js) - Google Analytics