gregorian-calendar

Is .NET giving me the wrong week number for Dec. 29th 2008?

Hi there According to the official (gregorian) calendar, the week number for 29/12/2008 is 1, because after the last day of week 52 (i.e. 28/12) there are three or less days left in the year. Kinda weird, but OK, rules are rules. So according to this calendar, we have these boundary values for 2008/2009 28/12 is week 52 29/12 is week...

Java 1.5 Calendar#compareTo() confusion

Ok, I'm officially stumped on this one. I have a GregorianCalendar object that I would like to determine if it is in the past, present, or future. So far, the Calendar#compareTo docs are confusing to me, in that I am getting erratic results. A simple test class will illustrate my problem: import java.util.Calendar; import java.util.Greg...

Creating a new NSCalendar calendar

I want to be able to convert between the Gregorian and Julian calendars (note: not "julian date") using NSCalendar on the iPhone. How can I subclass NSCalendar to use the Julian calendar? I want to do this without regards for 1582 or 1752 or any given year. ...

GregorianCalendar

I am doing an assignment and it involves using the GregorianCalendar. The specs say I need to use setLenient(false); how do I do this? I also need to set a constant date (1/1/2009) so that the first day of my program is always that. It also says to access the day, month and year through this: get(1) //returns the year get(2) // returns...

GregorianCalendar constant date

Ok, I want to make my program print out the date: 1/1/2009 But this is what it prints out: Thu Jan 01 00:00:00 EST 2009 From this code GregorianCalendar startDate = new GregorianCalendar(2009, Calendar.JANUARY, 1); public void setStart() { startDate.setLenient(false); Date date = new Date(startDate.getTimeInMillis()); Sy...

GregorianCalendar months

GregorianCalendar startDate = new GregorianCalendar(2009, Calendar.JANUARY, 1); SimpleDateFormat sdf = new SimpleDateFormat("d/m/yyyy"); public void setStart() { startDate.setLenient(false); System.out.println(sdf.format(startDate.getTime())); } When I run this code, I get 1/0/2009. I also get the same thing when I change the ...

adding days to a date

I have a program that needs to start on 1/1/09 and when I start a new day, my program will show the next day. This is what I have so far: GregorianCalendar startDate = new GregorianCalendar(2009, Calendar.JANUARY, 1); SimpleDateFormat sdf = new SimpleDateFormat("d/M/yyyy"); public void setStart() { startDate.setLenient(false); ...

Last sunday of a year in c#

Hi guys, How can I get date of last sunday of a year in C#?? Will gregoriancalendar class be of help? ...

Why does GregorianCalendar.getInstance contain a calsys and cdate of type Julian Calendar

I tried to do set date value to a PreparedStatement with default value but the value is sometimes returned as a JulianValue. For example (Assume spanBegin and spanEnd are null) Calendar cal = new GregorianCalendar(); if (spanBegin == null) { cal.set(0000, Calendar.JANUARY, 1); spanBegin = cal.getTime(); } if (spanEnd == null) {...

Have you ever had a requirement for a non-Gregorian calendar date, in a database application?

Context: I notice that the major databases support only the Gregorian calendar. Thus, it would seem difficult to build a database app with anything other than the Gregorian calendar. If you have ever used a non-Gregorian date in a database app, I would be curious to know the context of your use case. For example, if you live in India, ...

How to set a BCE year using GregorianCalendar

I have an assignment that converts dates from one calendar system to another. The documentation for GregorianCalendar seems to suggest that you can use dates with BCE years, but I have no idea how. If I simply make the year negative, i.e. GregorianCalendar cal = new GregorianCalendar(-20, 1, 2, 3, 0, 0); System.out.println(cal.getT...

Convert a string to a GregorianCalendar

How do a I take an input birthday string such as 02 26 1991 and make it into a Gregorian Calendar? I tried parsing it first but it keeps giving me an error message so I'm not quite sure what I'm doing wrong. I also have other input data before this date. One is another string and one is a double value. ...

Converting a birthdate into milliseconds

How do I take a birthdate entered by a user and turn into milliseconds so that I can calculate how old they would be on a different planet Here is the code I have so far: DateFormat df = new SimpleDateFormat("MM dd yyyy"); Date dateBirth = df.parse(birthdate); Calendar calBirth = new GregorianCalendar(); calBirth.setTime(dateBirth); ...

Java: What/where are the maximum and minimum values of a GregorianCalendar?

What are the maximum and minimum values of a GregorianCalendar? Are they in a constant like Integer.MAX_VALUE, or maybe GregorianCalendar.get(BLAH)? In a nutshell, how can I create a GregorianCalendar instance with min/max value? ...

Is there a way to add methods to GregorianCalendar in Java?

I'd like to make a method called "isBetween" returning a boolean, seeing if a GregorianCalendar date falls between two others. Alternatively, I'd like to just define operators of < and > for the class. I'm pretty new to Java, so I'm not sure....can I even do either of those? If so, how? ...

JDOQL (datanucleus) query compiling error in GregorianCalendar field

Following query gives a NullPointerException when complie it. Query query = pm.newQuery(Festival.class); query.setFilter("this.startDate == sDate"); query.declareImports("import java.util.GregorianCalendar"); query.declareParameters("GregorianCalendar sDate"); query.compile(); Class: public class Festival{ ... private G...

Problem with Gregorian Calendar hour of day in java

hi, I'm using a Gregorian Calendar to set a specific date and time to an application using the set function of the Gregorian Calendar. When i use the getTime() method, it gives me the right output however when i try to access the Hour_Of_Day and Minute it gives a wrong number. Calendar time = new GregorianCalendar(); time.se...

GregorianCalander

Hey guys, I know this is a very simple question but I am new to Java so please bear with me. I have create a program that can calculate the time a book is due to come back after being issued! So please help me out. Here is the piece of code that I have: public void loan(int numOfDays) { if( onLoan == true) { System.out.print...

Google App Engine JDO error caused by GregorianCalendar ?

My class looks like this : import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.Persistent; import javax.jdo.annotations.PrimaryKey; @PersistenceCapable(identityType=IdentityType.APPLICATION) public class Contact_Info i...

How can I determine if a string is a Hebrew or Gregorian date?

Hi, I have a string value that contains or a Hebrew date, or a Gregorian date. How can I determine if it's Gregorian or Hebrew in C#? ...