Questions tagged [java.util.date]

Through Java 7, the official class for representing a moment in time, using a thin wrapper around the number of milliseconds from epoch (1970-01-01). In Java 8, java.time.Instant and related classes were introduced as a replacement.

In the JDK through Java 7, the java.util.Date class is very widely used and contrary to what its name suggests, represents an instant rather than a "date" (i.e. a particular day). Date objects are mutable.

In Java 8, a new package java.time was introduced, which contains java.time.Instant to be used to represent an instant. This package should be preferred over using the old java.util.Date classes when writing new code.

323 questions
0
votes
0 answers

how can i run time in my java application without threads?

I want to get current time to my java app and want to make time running.If i use thread class my app is getting slower and slower. How can i aware this? Is there any method of running time? Here is my code:- new Thread(new Runnable() { …
Shiwantha
  • 11
  • 2
0
votes
1 answer

How can I use a string as a month name parameter

I have an excel file with dates in this format 31/08/13. What I need to do is to calculate a monthly interest based on the dates. The problem is that I need to know the number of days of the month. Here is how I'm getting the month name inside of a…
Slim
  • 1,708
  • 5
  • 37
  • 60
0
votes
1 answer

Store HH:MM:SS with Date field in web application(Spring+Hibernate)

I am working on a REST API using Spring and Hibernate. For the PUT operation I need to store the time along with the date. From my investigation, I found out that the application is returning the time along with the date. But while writing this…
Rakesh Gourineni
  • 1,361
  • 5
  • 16
  • 30
0
votes
1 answer

How do I convert a Date to an int?

I have this DateFormat dateFormat = new SimpleDateFormat("MM"); Date date = new Date(); I know the value as 10 but have got no idea how to print it out. How do I convert it to an int? If there even is a way?
0
votes
2 answers

Java - getting consistent UTC values irrespective of server

I am work on a version of a product which will be used by the users in India and am working from India (GMT+5:30). Our Servers are in US. Some scheme is to be applied which has a start date and end date (eg - From Aug 01, 00:00:00 to Aug 31 11:59:59…
abhihello123
  • 1,668
  • 1
  • 22
  • 38
0
votes
1 answer

Accessing Date without creating reference variable

We need to create a reference variable of class "Date" if we want to return date. import java.util.*; class Demo { public static void main(String args[]) { Date date=new Date(); System.out.println(date.toString()); }} Can we return date and time…
Neha Gupta
  • 847
  • 1
  • 8
  • 15
0
votes
0 answers

Why has java.util.Date been deprecated?

I apologize if this is like a dumb question, especially for all of you super-professional programmers out there. I am just beginning to program in Java, and I am starting to do basic things like scheduling procedures which requires comparing the…
jeffery_the_wind
  • 17,048
  • 34
  • 98
  • 160
0
votes
1 answer

Java: Speeding up and slowing down time

I'm trying to figure out the logic to set an arbitrary time, and then have that time "play back" at different speeds (like .5x or 4x real time). Here is the logic I have thus far, which will playback the time at normal speed: import…
mainstringargs
  • 13,563
  • 35
  • 109
  • 174
0
votes
1 answer

Java - Calendar / Date difference - Find difference down to seconds

Trying to make a little Countdown program in Java. I am working on the finding the difference between the dates part of the app, and for some reason I am only getting the days. I want the days, hours, minutes, and seconds. I am not sure why my…
cbaze19
  • 5
  • 1
  • 3
0
votes
3 answers

How to convert java.sql.Date to java.util.Date in dd/MM/yyyy format?

I am storing a date to database by converting util date to sql date by using following code SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); sdf.setLenient(false); java.sql.Date dobSQLDate = null; Date date =…
vikas devde
  • 11,691
  • 10
  • 35
  • 42
0
votes
1 answer

How to display current date in text format on textview in android using android.text.format?

I am getting result as 12/1/2012 but I want to display as "Saturday December 1,2012" my code is as below please give me a solution if you have...... Date date = new Date(); myDateString =…
user1791327
0
votes
2 answers

Error while calculating java Date difference

Calculating the difference between two dates (java.util.Date) in terms of no. of days look like very simple and we can find different ways to do that. I used the following code to calculate the date difference: public static long…
Manoj Shrestha
  • 4,246
  • 5
  • 47
  • 67
0
votes
2 answers

Date/time conversion/arithmetic

I've below code in Java 1.7: DateFormat df = DateFormat.getInstance(); Date startDate = df.parse("07/28/12 01:00 AM, PST"); The above date time (07/28/12 01:00 AM, PST) is in the properties file which is configurable. If this date time is already…
Mike
  • 7,606
  • 25
  • 65
  • 82
0
votes
2 answers

Java date older than 1923

So I have a strange problem, I have a java swing application that has the date 10/11/1922 00:00:00 MST but when it sends that date to my backend glassfish server via RMI the date becomes 10/10/1922 23:00:00 MST. So it is somehow losing an hour, is…
EpicOfChaos
  • 822
  • 11
  • 23
0
votes
1 answer

Convert a string to java.util.date AND preserve the timezone information

Before anybody downvotes this question, I have browsed the web and StackOverflow for the situation that I am facing and did not find anything, hence I am posting as a new question. I have a situation with java date and timezones. Situation: There…
Sunil
  • 1,238
  • 3
  • 13
  • 21