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
2 answers

find day of week for user birth date input

okay so I'm trying to create a program in which a user with input their day of birth in the dd/mm/yyyy format (or something similar). My teacher and I have a hard time connecting, mostly due to my hectic schedule so she can't always help. I'll post…
kandaspohn
  • 89
  • 1
  • 12
0
votes
1 answer

Java Date library accepts bad dates

I'm trying to work with dates and experiencing a problem: java.util.Date library accepts bad dates from file for example: 2014/99/99 . Later it somehow converts it and from 2014/99/99 I get 2022/04/09. Is there an easy way to cope with this…
Justin
  • 533
  • 2
  • 6
  • 16
0
votes
2 answers

drools working with dates

In official documentation I can't find any information how to write conditional statements for java.util.Date type fact fields in guided rules. For example how to compare such field to current date, check if it is equal omitting time, or check if it…
jinalu
  • 21
  • 1
  • 4
0
votes
0 answers

Why it is bad, that java.util.date is mutable?

I've been reading about drawbacks of java.util.date for a while, but I can't understand why it is bad, that java.util.date is mutable?
tomdavies
  • 1,896
  • 5
  • 22
  • 32
0
votes
2 answers

Getting java.util.Date Object As (10/7/14 ) From Another java.util.Date Object (Tue Oct 07 11:21:00 IST 2014)

Am facing problem while using @Temporal(TemporalType.DATE) recently we started migrating our project from struts2 to spring while we are using @Temporal(TemporalType.DATE) in struts2 for a java.util.Date field able to retrieve the Date field data…
0
votes
2 answers

Java date Conversion issue having input date as String Oct 2014

I need to implement the logic whether input date such as SEP 2014, OCT 2014 , NOV 2014 etc is current month or not. I have written below logic for checking whether a selected week is a current week or not using below method but not able to implement…
0
votes
1 answer

XStream marshalling unmarshalling XMLGregorianCalendar and Java.util.Date

Firstly a bit of background information an please forgive me if the format isn't correct. I have two objects I am trying to map back and forth from via XML. One is auto-generated via wsimport so I am not able to use JAXB or XStream annotations. The…
Desynchronous
  • 13
  • 1
  • 4
0
votes
2 answers

Method to calculate the upcoming birthdays in next N days

I need a method which takes an integer input (N) and returns the birthdays in the next N days. I am finding it very difficult to get any code running. Below is just a code of how I want it to work - it is in no means a working code. Any help is…
NanoNi
  • 315
  • 4
  • 16
0
votes
2 answers

conversion from util.Date to sql.Date not working

Why does the below query return this error message: 'data exception: invalid datetime format'? I have researched this and there does not seem to be anything wrong with it? java.util.Date today = new java.util.Date(); releaseDate = new…
Yohi
  • 39
  • 6
0
votes
6 answers

Unparseable date: "2013-05-16 09:35:31.0"

I am getting Parse exception while converting String to date. Here s my code: String str_date = commonAttrMap.get("updateDate").toString();//2013-05-16 09:35:31.0 DateFormat formatter; Date date; formatter = new SimpleDateFormat("yyyy-MM-d…
Mayank_Thapliyal
  • 351
  • 2
  • 7
  • 16
0
votes
0 answers

jDateChooser casting MsSql date

I have problem with capturing user date input from jDateChooser to insert into mssql table. There similar problems in stackoverflow. It was not solving my problem. Here is code that I capture user date entry…
user3498019
  • 95
  • 1
  • 2
  • 10
0
votes
1 answer

How to convert String into Date object using "DateFormat"?

I am trying to convert the date/Time of my machine into GMT time zone by using the following code: DateFormat gmtFormat = new SimpleDateFormat("E MMM dd HH:mm:ss 'GMT' yyyy"); TimeZone gmtTime =…
Neno M.
  • 123
  • 1
  • 6
0
votes
1 answer

How to insert java.util.Date object holding date and time into mysql database

I am using following code to insert a java.util.Date object in MySQL. d1 is date object I'm getting from a function. I tried casting java.util.Date into java.sql.Date but this doesn't save the time part. String sql = "INSERT INTO abc " + …
cks
  • 83
  • 1
  • 2
  • 9
0
votes
3 answers

Create a Java Date from a String and vise versa

I have a date in Integer format(YYYYMMDD). And a start_time as a String (HH:mm 24 hour system). and a time_duration in hours as a double. int date = 20140214; String start_time = "14:30"; double duration = 50.30; I want to use these 3 values and…
prime
  • 14,464
  • 14
  • 99
  • 131
0
votes
2 answers

Compare last modified time of file on google drive and file which is stored on local machine

I am developing an application which will check the last modified time of a file from google drive and last modified time of file on local machine, and compare them, if file on the local machine is found to be latest modified then it will be…
Mayur
  • 789
  • 10
  • 37