Skip to main content
Filter by
Sorted by
Tagged with
-2 votes
2 answers
266 views

I am working on a Java 8 application where I receive epoch millisecond timestamps that represent UTC time. I need to pass these timestamps as Date objects to a method that I do not control (from a ...
buggy's user avatar
  • 37
-3 votes
1 answer
107 views

I have a date "08-10-2020". I want to set that string into a java.util.Date property in the same format. But even after using SimpleDateFormat to format the date, it is still setting in &...
Armaan Brar's user avatar
0 votes
0 answers
73 views

My table has a TIMESTAMP column. Per our convention all times in the db is supposed to be in 'UTC'. When I insert a java.util.Date it is converted using the JVM's default TimeZone. There seems to be ...
Thomas Kiesling's user avatar
0 votes
2 answers
464 views

Let's get this over with. How do you convert a LocalDateTime to a java.util.Date without any "magic tricks" pulled by Java (which are becoming less and less amusing to me)? The year, month, ...
Cagepi's user avatar
  • 329
1 vote
1 answer
194 views

I am upgrading a groovy app from JDK11 to JDK17. One error I had to debug was with the following code: public static def getDayFromDate (Date date) { return date[Calendar.DAY_OF_MONTH] } For those ...
Reed M's user avatar
  • 312
0 votes
1 answer
406 views

I have a model class with 'Date' type field. //Model.java private Date createDate; I am trying to convert the database value of this createDate (which is YYYY-MM-DD format) to MMM d, YYYY, i.e., I ...
Suganya Rajendran's user avatar
0 votes
0 answers
188 views

Ran into a puzzling situation... My Groovy (4.0.18) app is working smoothly (thanks to all the help I received!) So with IntelliJ's help I packaged it up into a jar file including all dependencies and ...
H. Dog's user avatar
  • 357
4 votes
2 answers
2k views

We've recently transitioned our application from Java 11 to Java 17. Subsequent to the deployment, we've noticed that certain records exhibit a discrepancy where dates are displaying with a one-day ...
Vivek Buddhadev's user avatar
-2 votes
1 answer
79 views

The code looks like this: LocalDate.of(year,1,1).with(WeekFields.of(Locale.ENGLISH).weekOfWeekBasedYear(),weekNumber).with(DayOfWeek.MONDAY) But when I count 49 weeks for this year, which is 2023, ...
Rab Zhu's user avatar
-4 votes
1 answer
123 views

I am trying to convert java.util.Date to java.util.Date but in different format Wed Oct 11 10:00:00 CDT 2023 --> 2023-10-11T10:00:00.000Z I show lot of post and also tried different solutions ...
Hitesh Kumar's user avatar
2 votes
1 answer
20k views

I have an instance of the Date class and a time zone (e.g Europe/London). How do I convert this into an Instant? Is the below the correct way of doing this? LocalDateTime localDateTime = LocalDateTime....
kcon123's user avatar
  • 532
2 votes
2 answers
180 views

I was going through the different ways that we can get Date and Time in java, while reading the documentation could not understand what the below quote mean. Unfortunately, the API for these ...
Leveling_up's user avatar
0 votes
1 answer
845 views

I'm trying to convert a java.time.LocalDate to java.util.Date, but I lose some days in the process. Here the code that shows the issue: public static void main(String[] args) { var localDate = ...
Abadellatif Abazine's user avatar
-1 votes
1 answer
202 views

My approach : // initailize date object Date date = new Date(); // get time zone ZoneId zoneId = ZoneId.of("Asia/Dubai"); // create zonedDateTime object ZonedDateTime zdt = ZonedDateTime....
P Roopasree's user avatar
0 votes
1 answer
77 views

I am trying to compute the duration Of each Project and each Task appointed to the Project, unfortunately it always returns 0. computeDuration: Date minDate = projectTasks[0].gettaskFromDate();...
dannyph's user avatar
  • 19
1 vote
0 answers
85 views

I am trying to get the current UTC time and convert it into a Date object: OffsetDateTime now = OffsetDateTime.now(ZoneOffset.UTC); Date date = Date.from(now.toInstant()); The problem I ...
Joel's user avatar
  • 95
-1 votes
1 answer
1k views

Java uses java.util.Date to save timeStamp type fields in postgresql database, and finds that there is no time, minutes and seconds, only year, month and day, which is very strange. I have tried to ...
wantToADaShen's user avatar
5 votes
1 answer
1k views

I am having trouble with converting old dates from java.time.LocalDateTime to java.util.Date I tried a lot of variation and it still has the same shifted dates. I would assume that it is some weird ...
Nap's user avatar
  • 8,380
0 votes
0 answers
27 views

I want to get the week number from the date picker that user select even if the date was past date; String dateofweek= dateselect.getText().toString(); SimpleDateFormat format = new SimpleDateFormat(&...
VANSH AMBAWAT's user avatar
0 votes
2 answers
352 views

I have an .sh script on my Linux server. I need the date in milliseconds in Java, but everything I find on the net is giving me Unix Timestamp. Like this: date=$(date -d 'today 00:00:00' "+%s&...
Netuddki's user avatar
1 vote
1 answer
775 views

I have a use case where I get timeZoneId in UTC +/- format as String. Based on that I need to set correct timeZone in Java. Does anyone know the correct way of doing it? For example: String timeZoneId ...
kandarp's user avatar
  • 1,121
3 votes
3 answers
607 views

We faced following problem: SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy", java.util.Locale.GERMAN); String dateInString = "06-04-1980"; Date date = ...
anm's user avatar
  • 545
-1 votes
1 answer
1k views

Does anyone know how to grab or create the cdate value from Date? I haven't been able to figure out how to do so and I don't know how to necessarily get it. In the Date class it is there as ...
KennyL123's user avatar
0 votes
2 answers
91 views

I have a Grails 4.0.3 rest api in production running since last year without major problems. Unfortunately since last week It is in trouble because of some RabbitMQ request in the queue. My applicaion ...
D Nunes's user avatar
  • 93
0 votes
0 answers
183 views

I have a table in PostgreSQL that stores dob as datatype timestamp without timezone example value '1997-12-03 07:00:00'. My entity class is as follows @Table(name = "customer") ...
sia's user avatar
  • 1
1 vote
1 answer
456 views

I have a legacy application that is passing Date using java.util.Date and a new service that is providing date using java.time.ZonedDateTime . My use case is to compare both the dates and ...
Kodeffeminate's user avatar
0 votes
1 answer
106 views

My requirement is to convert the string "2019-04-25 07:06:42.790" to Date Object with same format as "2019-04-25 07:06:42.790". I tried to do this, but it is always giving in ...
Vikas's user avatar
  • 21
1 vote
1 answer
858 views

Yes, I understand that java.util.Date is extremely outdated. That being said, is there a way to represent dates before 1 CE using this class, or must I migrate to a different class?
user avatar
1 vote
2 answers
4k views

I have a value of type java.util.Date which was obtained from a legacy third-party API. Is there a direct way of converting it to kotlinx.datetime.LocalDateTime? I know how to do it only in a ...
k314159's user avatar
  • 12.5k
1 vote
0 answers
103 views

So below is the code I made to create a register form for user to register for new account. signUp.html <form class="user" method="post" action="signUp.jsp"> &...
yong's user avatar
  • 37
0 votes
3 answers
2k views

I have a method wherein have to check whether a LocalDate falls in between two java.util.Date values. there are methods after and before in java.util.Date and there are methods isAfter and isBefore in ...
Scientist's user avatar
  • 1,474
0 votes
4 answers
5k views

I have a json formatted response Date to the controller that is like this: @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "America/Chicago") private Date date; So when I ...
stackerstack's user avatar
3 votes
3 answers
3k views

I have a datetime type column in mysql db and file fetching column using jdbctemplate and type casting it to java.util.Date throws error. Here is my code : I have defined the following ...
Vinayak Nair's user avatar
0 votes
1 answer
163 views

Using the following code in Java8 - newTable.LogDate = Date.from(ZonedDateTime.of(year, month, day, 0, 0, 0, 0, ZoneId.of("GMT")).toInstant()); The LogDate is ending up adjusted for my (and ...
Coyttl's user avatar
  • 534
-2 votes
2 answers
1k views

This code example uses 3 time zones (EST, PST, EET). For each Time Zone, a Date object is created and the toString() is run to print out the format being used. Then this same String value is passed to ...
Unhandled Exception's user avatar
2 votes
4 answers
11k views

I'm trying to convert a java.util.Date to java.time.LocalDate: [java.util.Date instance].toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); However, there is a case when [java.util.Date ...
MarekChr's user avatar
  • 1,196
0 votes
0 answers
720 views

I have an elastic search db deployed within an AWS VPC. It holds millions of records all with a timestamp added based on the unix datestamp (new Date().getTime()). I am trying to pull (1) record per ...
Adam Kramer's user avatar
0 votes
2 answers
2k views

I can not find my error. The program says that can not fin class Date. Please help me to find the error. It is a inheritance and Polymorphism class. I have classes: GeometricObject, Circle, and ...
NewLifeFL's user avatar
-2 votes
1 answer
158 views

I have a String s = "2020-02-22"`; and I want to change it to Date so I can store it in my database which has has a column that does not accept anything but Date. I tried using the ...
sammy's user avatar
  • 3
0 votes
1 answer
656 views

In this code, String str="Sun Feb 07 00:27:16 CET 2021"; SimpleDateFormat sdf=new SimpleDateFormat("E MMM dd HH:mm:ss z yyyy"); try { java.util.Date date=...
يونس's user avatar
1 vote
0 answers
77 views

try { SimpleDateFormat format = new SimpleDateFormat("YYYY-MM-DD'T'HH:mm:ss+hh:mm"); Date dateTime = format .parse("2020-11-22T05:57:10+01:00"); System.out.println(...
Dnyaneshwar Jadhav's user avatar
-2 votes
3 answers
291 views

I have a kind of complex problem that I hope I can get some help on. My teacher has asked for a homework question that we find how long it took us to type a sentence "Hello World!" and print ...
AJ Mosley's user avatar
-2 votes
2 answers
2k views

In my Java College Class, I have to create the class Customer. A customer has to have a first name, the last name, a birthday and an address. The problem I have is to fill the default constructor ...
Sye's user avatar
  • 1
1 vote
2 answers
865 views

There is requirement to see if some date (ex: expiry date) is greater than or equal to today. Presently JODA time library has been used to achieve this simple comparison. Even some post are ...
Anuja Paradkar's user avatar
0 votes
1 answer
167 views

I'm designing a simple covid 19 tracking system. The system creates Visits object that is stored in an ArrayList everytime a Customer(objects in ArrayList) visits a Shop(objects in ArrayList). The ...
mayfly orin's user avatar
1 vote
1 answer
2k views

Recently I'm having a problem with Timestamp and HTML input type Date: This is my HTML/JSP: <div class="form-group"> <label>Your day of birth</label> <input class=&...
Jason's user avatar
  • 13
0 votes
3 answers
149 views

I am searching for a method to get the last third of two dates. first example: Date 1 = 22:00 Date 2 = 01:00 (next day) calculateLastThird(); (output: 00:00) second example: Date 1 = 22:25 Date 2 = ...
Unknownscl's user avatar
10 votes
2 answers
14k views

How can I convert TemporalAccessor to java.util.Date? TemporalAccessor accessor = functionReturnsTemporalAccessor() Date date = Date.from(accessor) Date.from() does not accept TemporalAccessor, is ...
Dániel Kis's user avatar
  • 2,651
0 votes
2 answers
2k views

I use this function to parse strings into a date format fun formatTimestampEDDMMMYYYY(date: String): String { return E_DD_MMM_YYYY.format(Date.parse(date)) } Whilst it works perfectly the gradle ...
AndroidDev123's user avatar
-1 votes
4 answers
6k views

I am getting the current time in epoch. How can I add 1 month in future? Date date = new Date(); int epoch = date.getTime(); Datatype for epoch - integer($int64) To be precise: I want to add 30 ...
user3384231's user avatar
  • 4,083

1
2 3 4 5
7