Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
156 views

This is August 2025: August 2025 Mon Tue Wed Thu Fri Sat Sun 1 2 3 4 5 6 7 8 9 10 --> 11 12 13 14 15 (16) 17 18 19 ...
Francesco Sblendorio's user avatar
0 votes
2 answers
137 views

is there any way to calculate calendar days between two dates. I tried with below code but looks like it gives 1 day as answer. But I am expecting the difference between this date is 2 days. No need ...
JAVA_CAT's user avatar
  • 881
-2 votes
1 answer
228 views

I'm writing an app that must find some time for alarm (from Date object), and then should subtract several hours and minutes (by using Calendar object) selected by the user (interval, several hours ...
Binyamin Pekar's user avatar
-1 votes
1 answer
158 views

I'm trying to get java.util.Calendar date field as following. This is the DTO. import java.util.Calendar; public class ImportExportProgressDTO { private Calendar prolongedDate; } public void ...
Shubham Patil'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
1 vote
0 answers
322 views

I would like to print the correct TimeZone abbreviation of a Date in Android but I'm a little confused. As far as I know in the "Europe/Budapest" TimeZone we have "Standard Time" ...
Adam Varhegyi's user avatar
0 votes
3 answers
160 views

I have the following code and trying to figure out if the date difference is greater than one year or not. If I have the two dates like this: 2022-08-20 10:26:44.000 2023-08-25 10:26:44.000 How ...
Tan's user avatar
  • 1,613
0 votes
3 answers
2k views

I need to get this week startdate like 2023-02-20 and last week startdate and end date. startdate will be monday. so I create 4 variables like below. private var thisWeekStart : Long = 0 private ...
Hyejung's user avatar
  • 1,314
1 vote
0 answers
117 views

I'm writing some integration of legacy code that expects date/time as a GregorianCalendar. So, I'm creating the GregorianCalendar using from(ZonedDateTime) method. However, the result is showing some ...
L. Holanda's user avatar
  • 4,701
0 votes
0 answers
56 views

import java.util.*; enum CITY{ROME,BUDAPEST,PARIS,GREECE,TALIN,AMSTREDAM,VIENNA;} class Flight{ private String flightName = "AirBus"; private int ticketPrice = 50; private CITY ...
inspironman's user avatar
0 votes
0 answers
201 views

The code simply extract the time portion of two timestamps and sub them from each other to get the duration import java.util.Calendar; public class Test { public static void main(String[] args) { ...
A.Alqadomi's user avatar
  • 1,589
1 vote
0 answers
33 views

String pickupdate = pdate.getText().toString().trim(); // String dateBefore = "25/10/2022"; // create instance of the SimpleDateFormat that matches the given date ...
Shahzad Ali's user avatar
0 votes
1 answer
59 views

Why this code is an infinity loop? How I can fix it? Calendar cal = new GregorianCalendar(); cal.setTime(new Date()); while (cal.SECOND < 20){ System.out.println(cal.SECOND); } Thanks you in ...
rates336's user avatar
0 votes
2 answers
427 views

Trying to store data into a string. This is my utilities. public class CommonDatePicker { public static void datePicker(final TextView textView, Context context) { Calendar dateCalender = Calendar....
Uncle Roger's user avatar
0 votes
1 answer
3k views

I have a back-end job that runs once a day and is scheduled at a particular time based on the entity/user etc. Now, I want to validate if the current time is earlier than the job, if yes, then job can ...
nick235's user avatar
4 votes
2 answers
356 views

First, I want to state that I know the Java Calendar class is being supplanted by other libraries that are arguably better. Perhaps I've stumbled upon one of the reasons Calendar has fallen out of ...
Jonathan Cameron's user avatar
0 votes
0 answers
127 views

Calendar now = Calendar.getInstance(); System.out.println("Current date : " + (now.get(Calendar.MONTH) + 1) + "-" + now.get(...
Sunil S R's user avatar
0 votes
2 answers
236 views

I'm writing an app for android. On the start of it I create a Calendar, filling such containers as YEAR, MONTH, DAY_OF_MONTH, ERA and time zone as GMT. I get something like this java.util....
csgbsk's user avatar
  • 19
0 votes
0 answers
716 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
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
3 votes
1 answer
803 views

TL;DR: I'm getting a strange result when setting a GregorianCalendar with a custom Julian->Gregorian cutover date. 1 Jan 1800 becomes 12 Jan 1800, where 1800 is before the custom cutover date (31 ...
frIT's user avatar
  • 3,325
0 votes
2 answers
2k views

I use the following code to add one day to the calendar. However, I want to retrieve in a string only the date without the time. Is this somehow possible? Calendar calendar = Calendar.getInstance(); ...
stefanosn's user avatar
  • 3,324
-4 votes
3 answers
1k views

I'm new to Kotlin and while doing a course there was a bit where you worked with the current weekday. The course used this java code to get it: import java.util.* Calendar.getInstance().get(Calendar....
Gowther's user avatar
  • 13
0 votes
3 answers
207 views

I am wondering how I should be using java Calendar objects in order to use them properly (use of this class is mandatory for my assignment so while I'd love to use some of the better options - they ...
user-kk-'s user avatar
0 votes
2 answers
196 views

Calendar calendar = Calendar.getInstance(); Calendar cal1 = Calendar.getInstance(); if (calendar.getTime().equals(cal1.getTime())) { System.out.println("Hi!"); } ...
Hemlata's user avatar
  • 377
2 votes
2 answers
975 views

I am using the Calendar class in java and am having trouble. I have this code Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("NZST")); System.out.println("Calendar....
Simon Mitchell's user avatar
0 votes
1 answer
774 views

I am making a calendar that allows you to add a specific holiday which recurs each year automatically. My WorkdayCalendar.class needs 2 methods: -setHoliday(Calendar date) which sets a holiday only ...
Rosso's user avatar
  • 163
1 vote
3 answers
227 views

I have an ArrayList that contains date - [1, 5, 2020] // day|month|year I am adding this to calendar in this way: calendar.add(Calendar.DAY_OF_MONTH, dateList[0]) calendar.add(Calendar.MONTH, ...
Micro-Scope's user avatar
0 votes
1 answer
347 views

I am facing a problem I really don't understand. I am trying to use the set method on a Calendar but it modifies the values only if I print it, here is the code: Calendar cal = Calendar.getInstance();...
user12528175's user avatar
0 votes
3 answers
1k views

We will pass month information in yyyyMM format.From that given input how i will get FirstDate and LastDate of that month? Input:-202002 OutPut Should be:- First Date:- 2020-02-01, Last Date:- 2020-...
Tarik's user avatar
  • 159
0 votes
3 answers
375 views

I have some legacy code like this final Calendar cal = new GregorianCalendar(); cal.setTime(today); // changed on May-03-2004 //cal.set(Calendar.DAY_OF_WEEK, cal....
Archimedes Trajano's user avatar
3 votes
1 answer
854 views

java8 GregorianCalendar DOC A week year is in sync with a WEEK_OF_YEAR cycle. All weeks between the first and last weeks (inclusive) have the same week year value. Therefore, the first and last days ...
hiway's user avatar
  • 3,986
0 votes
1 answer
82 views

I want to get the date of SMS in format dd-MM-yyyy and time in format HH:MM (in 24hr format) on which it was received on phone. I use the following code Calendar calendar = Calendar.getInstance(); ...
AndroidLearner's user avatar
0 votes
1 answer
444 views

I hope it's not a JDK bug, or I am tempted to cash all my bank accounts and throw it in a mattress... Here is the code. Please note that setting the date to Dec.29 immediately rolls the year to 2020. ...
Alex Yershov's user avatar
0 votes
2 answers
1k views

import java.util.Calendar; public class WeekYear { static String input = "202001"; //static String format = "YYYYMM"; public static void main(String[] args) throws ParseException { ...
Gopi's user avatar
  • 949
-2 votes
4 answers
264 views

Hi can any one explain why such abnormal behavior from Calendar .after method Calendar cal = Calendar.getInstance(); Calendar cal1 = Calendar.getInstance(); cal.set(Calendar.HOUR, 14); cal1.set(...
Atul Singh Rathore's user avatar
0 votes
2 answers
1k views

calendar gets wrong unix time as I got. long millis = 1568814839L; System.out.println(millis); //1568814839 Calendar.getInstance(TimeZone.getTimeZone("Asia/Tashkent")); calendar.setTimeInMillis(...
sardorkun's user avatar
3 votes
1 answer
440 views

I'm working on some legacy code where java.util.Calendar is used for date related calculations (basically adding months). Now I want to replace java.util.Calendar by java.time.LocalDate in the code ...
Kohei Nozaki's user avatar
  • 1,162
5 votes
0 answers
65 views

I am currently ditching all usages of java.util Date implementations from my project and want to change everything to Classes from the java.time package. Now I found a usage of the roll method of a ...
zingi's user avatar
  • 1,415
3 votes
2 answers
937 views

I was studying the old Calendar API to see how bad it was, and I found out that Calendar has a roll method. Unlike the add method, roll does not change the values of bigger calendar fields. For ...
Sweeper's user avatar
  • 292k
0 votes
1 answer
292 views

I'm making an airplane reservation system with java and when I run the code, it results into an error. The error I'm receiving is: "Incompatible types: Date cannot be converted into calendar." And ...
user avatar
0 votes
1 answer
1k views

I was trying to get month value. But I wanted to check which is better, java.util or java.time to retrieve month value. This is my code to check performance of Calender vs ZonedDateTime. //import ...
Ujjwal Jung Thapa's user avatar
0 votes
3 answers
95 views

I have an app that use a calendar and I need to take the day of week. The problem is that it takes the correct day of week in all the dates around the year, except in July. I tried to add differents ...
Abraham's user avatar
  • 199
2 votes
4 answers
11k views

I want to add 30 days in my current date I searched a lot but did not get the proper solution. my code Date date = new Date(); SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-dd"); Calendar ...
A.J's user avatar
  • 143
1 vote
3 answers
3k views

In my project I need to to use current date and time. For this I'm importing java.util.Date. This import is working fine few hours ago. But I have an error in R file ( r cannot resolve ) and this ...
Ehtasham Ali's user avatar
0 votes
0 answers
163 views

I am converting the Calendar instance result.submissionDate to java.sql.Timestamp as below, am wondering is there any alternative efficient way to do this by avoiding creating new Timestamp object? ...
OTUser's user avatar
  • 3,858
-4 votes
1 answer
1k views

I have a piece of code like this: Calendar c = Calendar.getInstance(); long startTime = c.getTimeInMillis(); while (x < 10000000) {//check all the integers from 1 to 10000000 to ...
Kcits970's user avatar
  • 642
0 votes
1 answer
7k views

I am getting error for cannot find symbol getInstance(),Calendar.DATE,Calendar.MONTH,Calendar.YEAR This only occurs when I am running offline on VS Code. On running in on an online IDE (Hacker ...
Nuruddin's user avatar
3 votes
1 answer
10k views

I am writing a method that can advance the date by a given number of weeks. Here is my code: public class Date { int year; int month; int day; public Date (int year, int month, int day){ this....
Saad Hassan's user avatar
0 votes
1 answer
33 views

I have a Calendar instance that starts with the first day in December. I am trying to set that Calendar instance to the last Tuesday of the year. Somewhere between setting the last day of the year and ...
Baracus's user avatar
  • 630