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 to convert string to readable date

I have a timestamp value "20150616182115452" which is "yyyyMMddHHmmss ", and i wanted to format it to "dd/MM/yyyy hh:mm:ss" . i have tried String lastLogon = db.getDataAt(0,"VG_QRSE006_L_LGN_TIMESTAMP") ; SimpleDateFormat…
hiboss
  • 317
  • 6
  • 15
0
votes
1 answer

Inserting date from JDateChooser to Oracle DB

I am having trouble inserting a date for the jDateChooser into my oracle db. Below is the action event in the class staffDisplay. `public void saveButtonPressed(ActionEvent e){ try{ int result = staff.addStaff( …
Clyo
  • 3
  • 3
0
votes
2 answers

SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ") parse in java gives wrong date?

I used this SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").So when I pass date 2016-01-01T10:30:00-0800 more than or equal to 10:30:00-0800 time then it will parse(date) response which is next day date 2016-01-02T00:00:00+0530 which is not expected.It…
0
votes
1 answer

Error while parsing date from json to object

I have a json as {"redemptionStartDate":1436950251941,"redemptionEndDate":1500108651941} and I am trying to parse this json into an object which has date objects(java.util.Date) as private Date redemptionStartDate; private Date…
Rajat Nigam
  • 271
  • 1
  • 9
  • 26
0
votes
0 answers

How to convert sql.date to util.date so that i can set that date to JDateChooser?

I'm trying to convert sql.date which i'm getting from my sqlite database to util.date. And i want to set that date to JDateChooser. I've literally tried all possible ways but it seems i'm missing something. Can anybody tell me what's wrong? try{ …
Parag Pawar
  • 827
  • 3
  • 12
  • 23
0
votes
0 answers

Change format date in Java does not work correctly

public class CronoProgrammaForm { ... java.util.Date datPreIniLav; //getter and setter ... } Main SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); …
Dave
  • 1,428
  • 4
  • 31
  • 49
0
votes
3 answers

Round java.util.Date to end of day

I want to round a java.util.Date object to the end of the day, e.g. rounding 2016-04-21T10:28:18.109Z to 2016-04-22T00:00:00.000Z. I saw Java Date rounding, but wasn't able to find something compareable for the end of the day. It also is not the…
0
votes
3 answers

Unable subtract days from date in java

I want to subtract days from date in java. But I dont want to use external libraries. I have referred some of questions from stackoverflow but they are suggesting to use external libraries. So I have applied following logic noOfDays = 24; Date…
sdk
  • 178
  • 2
  • 19
0
votes
3 answers

java.util.date() always showing GMT timing

We have one of our application hosted on a application server installed on machine working in CST timings. Now in the application footer we are showing the Last Login time and date using java.util.date().toString(); Now from reference of this post I…
Nikhil Agrawal
  • 26,128
  • 21
  • 90
  • 126
0
votes
0 answers

Java.util.Date() behavior

I was expecting the code below to print todays date and date 365 days ago public static void main(String[] args) { long YEAR_IN_MILLIS = 365 * 24 * 60 * 60 * 1000; Date curDate = new Date(); System.out.println("Todays date: " +…
Puru--
  • 1,111
  • 12
  • 27
0
votes
1 answer

How to insert into JDate chooser value into db

I have a JDateChooser in my form. and I need to insert it's Date value into DB. I used this method just after "public class Nonacademic extends javax.swing.JInternalFrame {" , and the method I used is mentioned below, public static java.sql.Date…
user5178776
0
votes
1 answer

Convert String to Date not working properly

I am getting a date by ajax in String format. But it is getting changed when I am converting it to date by SimpleDateFormat. The month is always changed to Jan. I am worried only about the month change.My code is given below String appointmentDate =…
abhishek
  • 51
  • 2
  • 11
0
votes
1 answer

java.util.Date return falsy date after parssing a string date

I'm trying to format a string that stores a date in format yyyy-MM-dd as dd-MM-yyyy. Here is my code : String dateString = "1991-08-03"; SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); Date date =…
bboulahdid
  • 329
  • 1
  • 4
  • 14
0
votes
1 answer

From TimePickerDialog to a Date

I'm looking for an efficient way to convert the hours and minutes i get from a TimePickerDialog into a Date object. I need it for a method which has to know whether the input Date is at MAX 12 hours from now(). So maybe you can enligthen me into a…
Mehdi
  • 713
  • 9
  • 19
0
votes
1 answer

java.lang.IllegalStateException while configuring custom attribute serializer in titan graph

I am trying to write a custom java.util.Date serializer for titan graph. Here is my titan configuration file: attributes.allow-all = true attributes.custom.attribute1.attribute-class = java.util.Date attributes.custom.attribute1.serializer-class =…