Getting current data and timestamps in java is requirement for most of java enterprise application. Formatting date in java or parsing date in Java is such a common functionality that you will need it now and than. Though most of programmer look Google for finding current date and timestamps code in Java, its worth to having an idea how you can do that by using java.util.Date class. some time you might need formatted data string say "yyyy-MM--dd:HH:mm:ss". That is also possible by using dateformat in Java. I have touched base on string to date conversion and now in this article we will see that in detail in terms of current date, time-stamp and timezone values. if you are working in global core java application which runs on different timezones you must need to include timezone in your date and timestamp to avoid any confusion.
Find Current Date Timestamps in Java Timezone Example
How to get current data and timestamp in GMT timezone
GMT timezone is sort of standard timezone for recording date and timestamp. if your application is not using any local timezone that you can use GMT for storing values on server. here is quick example of getting current date and timeStamp value in GMT timezone in Java.
Code Example of current date and timestamp in GMT
That’s All on this quick tip of getting current date and timestamp value on different timezones in Java. You just need to be bit careful because DateFormat and SimpleDateFormat are not Thread-safe in Java and should not be shared between multiple threads, otherwise it can create very subtle issues like incorrect Date.
How to convert String to Enum in Java with example
How SubString method works in Java
How to implement CompareTo in Java
How to Convert Double to String in Java
How to find IP address in Windows and Unix
How to implement Thread in Java
How to increase Heap in ANT and Maven
How to override Equals method in Java
No comments:
Post a Comment