Questions tagged [java.util.calendar]

The Java class for converting a moment in time (java.util.Date) to fields that represent the date (day, hour, minute, etc.).

The java.util.Calendar class has existed since Java 1.1. It allows conversion between the Date interpretation of "number of milliseconds" since midnight, January 1, 1970 UTC to fields such as year, month, day, hour, minutes, seconds, and milliseconds. These fields are mutable.

147 questions
0
votes
2 answers

Get next week dates if today is Sunday

How to get next week dates if today is Sunday? I want get dates of Monday to Saturday of next week. I am using following code get dates: private String[] getDaysOfWeek() { String[] days = new String[6]; SimpleDateFormat format = new…
Joe
  • 550
  • 2
  • 11
  • 21
0
votes
2 answers

Weird Value When Calculating Date Difference

I have been using the following code to calculate the difference between two dates and I have been getting an unusual error: if I pass the following dates: d1 = 08/12/2017 d2 = 31/07/2022 it returns: 24055.. isn't the result supposed to be return…
0
votes
2 answers

Compare java.util.Calendar date to java.util.Date

I need to compare a Calendar time to Date. I wrote below code. Calendar now = Calendar.getInstance(); now.set(Calendar.SECOND, 0); Date date = new…
GD_Java
  • 1,359
  • 6
  • 24
  • 42
0
votes
2 answers

How can I take a user inputted date instead of the current date in the Calendar class in Java?

I'm working on an assignment, and my goal is to create a class that prints the day of the week given a date. When prompted for input, if the user enters nothing, the program is stopped. Otherwise, if the user enters a date, the program provides the…
Brian
  • 47
  • 3
  • 9
0
votes
3 answers

Trying to reset Calendar In Java

I'm having problem when I try to reset the Calendar because it doesn't recover the original date. What am I doing wrong ? public static void main(String[] args) { Calendar from = Calendar.getInstance(); int contador = 0; while (contador <…
Jaume
  • 39
  • 1
  • 2
0
votes
2 answers

Jboss Java Date daylight saving time

Have an issue where, when clocks are moved due to a Daylight savings time (twice a year), dates are not correct in Java (I am based in Central Europe: GMT+2 in summer, GMT+1 in winter) If time is moved 1 hour ahead, new Date() still returns old time…
kandan
  • 715
  • 2
  • 12
  • 39
0
votes
2 answers

How to display the weekend in different font color using Calendar class in Java?

Currently the font color is same for all the days in the calender, but I want to make weekend in different color. Calendar c = Calendar.getInstance(Constants.localeCosnt); int dateValue = c.get(Calendar.DATE); …
Vikash
  • 21
  • 1
  • 1
  • 6
0
votes
2 answers

Current week monday date

In my case week start from Monday to Sunday.I want get current week Monday date. I using following code to get Monday date. Calendar c = Calendar.getInstance(); c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); …
Joe
  • 550
  • 2
  • 11
  • 21
0
votes
0 answers

How to Convert Material Calendar View Selected date to java.util Date type

I use Android materialCalendar view library in one of my app,the user can select a particular date from the calendar view,i need to get the list of week days of that particular selected date .. i use the following code which retreives the current…
ashif-ismail
  • 1,037
  • 17
  • 34
0
votes
1 answer

java calendar returns wrong hour_of_day

I have the following code: Calendar cal= Calendar.getInstance(); cal.set(Calendar.YEAR, 1994); cal.set(Calendar.MONTH, 03); cal.set(Calendar.DAY_OF_MONTH,1); cal.set(Calendar.HOUR_OF_DAY, 0); After running it I…
sgrossman
  • 105
  • 2
  • 7
0
votes
1 answer

java.util.Calendar.get* and java.util.Calendar.set* are blocking

on a multi thread application, there are locked threads, as i get the threaddump, it seems to be about the java.util.Calendar class, the object is created using Calendar.getInstance() which returns new Instance. Do you have any comment. here is a…
dursun
  • 1,861
  • 2
  • 21
  • 38
0
votes
3 answers

Time Conversion in Java without using Joda Time

My basic query is converting a time in a particular place to the corresponding time in another place . Eg: What is the time in Los-angeles when it is 23:30 in India ? What is the time in Los-angeles when it is 10:00 in Germany ? The inputs that…
Rasika Vijay
  • 395
  • 1
  • 7
  • 17
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
1 answer

Conversion of Date object to calendar object

I had a function called as setDueDate(Calendar arg0).But, the value in the field is Date of format "yyyy/MM/dd".Is there any way to convert Date object to Calendar and pass it to the function.
0
votes
1 answer

HTTP Status 500 - /gotit.xhtml @34,49 value="#{bean.nbrp.title}": Target Unreachable, 'nbrp' returned null

How to resolve this error? Target Unreachable,return null HTTP Status 500 - /gotit.xhtml @34,49 value="#{bean.nbrp.title}": Target Unreachable, 'nbrp' returned null gotit.xhtml
NBR
  • 29
  • 6