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
1 answer

Getting org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException when parsing fiql expression containing java.util.Calendar attribute

I use FIQL to query a web service built using Apache CXF 3.0.0-milestone1. When I attempt to reference any attribute of type java.util.Calendar I get a org.apache.cxf.jaxrs.ext.search.PropertyNotFoundException. I have tracked down the behavior to…
Ludovic
  • 1
  • 1
0
votes
2 answers

Unexpected value setting java calendar minutes

I am trying to create a time interval, as the starting point is the current time and the minimum and maximum values are calculated by a special variable which is set by the user (upperBound). So the code looks like: private static int upperBound =…
Monika X
  • 322
  • 4
  • 13
0
votes
1 answer

Why incrementing a counter in a for's body rather than in the header?

I've found the following piece of code in java.util.Calendar: public final void clear() { for (int i = 0; i < fields.length; ) { stamp[i] = fields[i] = 0; // UNSET == 0 isSet[i++] = false; } areAllFieldsSet = areFieldsSet…
stuXnet
  • 4,309
  • 3
  • 22
  • 31
0
votes
3 answers

Getting days in a current month

I want to display the arraylist like this: [2013-11-01,2013-11-8,2013-11-15,2013-11-22,2013-11-29] I am written the below code and i am passing the static values to that method: import java.sql.Date; import java.text.ParseException; import…
user2996174
  • 1,391
  • 4
  • 13
  • 20
0
votes
2 answers

java.util.calendar behaving strange

So, i found the java.util.Calendar, and tried to use it for a android project i'm working on. I do not understand at all how Calendar.DAY_OF_WEEK can return 7, when it's Thursday? And now when it's August Calendar.WEEK_OF_YEAR returns 4, which…
Johan Bjäreholt
  • 731
  • 1
  • 11
  • 24
0
votes
2 answers

How to set some days on Calendar.DAY_OF_WEEK

I need to set some days in method set. I try to use: c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); c.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY); but with this way set only Wednesday. Thank you and sorry for my english :)
Maxim
  • 123
  • 2
  • 7
0
votes
3 answers

java.util.Calendar

My application: System.out.print("Please enter date (and time): "); myTask.setWhen( input.nextInt(), input.nextInt(), input.nextInt(), input.nextInt(), input.nextInt()); My setter: public void setWhen(int year, int month, int date,…
John
  • 3
  • 2
-1
votes
2 answers

Gregorian Date to Date

This should be quite simple customerSearch.get("DateOfBirth") where customerSearch is a HashMap and it's a Gregorian Date. But I need a normal Date object. I tried Date dateOfBirth = new Date( ((GregorianCalendar)…
-1
votes
1 answer

Calendar.month and year broke?

Im trying to get the number of the month (from 1 to 12) of the year and the year. But when i use that code it give me only the number 2 for the month and the number 1 for the year. Calendar calendar=Calendar.getInstance(); String currentdate; …
Kyo R.C.
  • 13
  • 6
-1
votes
1 answer

Why Java calender object return wrong WEEK_OF_YEAR and WEEK_OF_MONTH

By the following way I set date object to calendar instance. But when I get the week of year , wrongly it returns week of the year as 1. Same as week of the year, week of the month value also wrong. It return as 6. But it should be 5. Following is…
gangatharan
  • 781
  • 1
  • 12
  • 28
-1
votes
4 answers

Not sure how to use getTime() with GregorianCalendar in Java

I'm getting a long printout of my GregorianCalendar when I only want to print the Year, Month, and Day. This is what I get:…
-1
votes
1 answer

Set Calendar with specific date and get wrong values for month

I am using this method to set time to the calendar but when I want to get month it'll give me month-1. For example when I set "2017-12-27 10:50:00". And when I want to get the month of the calendar it's 11 instead of 12. public String…
Ehsan
  • 2,676
  • 6
  • 29
  • 56
-1
votes
2 answers

What does cal.get(7) do from a Calender instance?

I am documenting some code and need help understanding this little line. private Calendar cal = Calendar.getInstance(); if ((this.cal.get(7) != 7) || (this.cal.get(7) == 1)) { What does cal.get(7) mean? I ran it on an IDE, and it gave me a result…
xem
  • 125
  • 5
  • 17
-2
votes
4 answers

Why Calendar.after always retun true?

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(Calendar.HOUR,…
-2
votes
3 answers

What is the Difference Between Calendar.DAY_OF_WEEK and Calendar.DAY_OF_MONTH? The output is same every time

I'm setting time using Timestamp class with current time. I'm setting the time with the Calendar class first by DAY_OF_WEEK and second with DAY_OF_MONTH. I’m getting the same output every time. Then what is the diffrence between DAY_OF_MONTH and…
Parminder Singh
  • 131
  • 3
  • 10
1 2 3
9
10