gregorian-calendar

Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch

我与影子孤独终老i 提交于 2019-12-01 09:15:32
Given that Gregorian Calendar start date is 15 Oct 1582, please consider the following tests and please help me understanding what happens: import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import javax.xml.datatype.DatatypeFactory; import org.junit.Test; @Test public void gregorianToDateConversion() { GregorianCalendar calendar = null; Date date = null; calendar = new GregorianCalendar(1582, 9, 04); date = calendar.getTime(); System.out.println("new GregorianCalendar(1582, 9, 4) -> calendar[DAY_OF_MONTH ["+calendar.get(Calendar.DAY_OF_MONTH)+"], MONTH ["

Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch

我是研究僧i 提交于 2019-12-01 06:32:23
问题 Given that Gregorian Calendar start date is 15 Oct 1582, please consider the following tests and please help me understanding what happens: import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import javax.xml.datatype.DatatypeFactory; import org.junit.Test; @Test public void gregorianToDateConversion() { GregorianCalendar calendar = null; Date date = null; calendar = new GregorianCalendar(1582, 9, 04); date = calendar.getTime(); System.out.println("new

Gregorian to Hebrew

只谈情不闲聊 提交于 2019-12-01 00:06:30
How to convert a gregorian date into the equivalent hebrew date? Also please tell about these calendars as I am not having much knowledge of these. There's a handy class called NSCalendar . You create one like this: NSCalendar * gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSCalendar * hebrew = [[NSCalendar alloc] initWithCalendarIdentifier:NSHebrewCalendar]; Once you've got the calendar objects, you can use them to convert a date around to various representations: NSDate * date = [NSDate date]; NSDateComponents * components = [gregorian components

Adding Days to Calendar

自作多情 提交于 2019-11-30 19:43:53
I'm new to this site and I have just started learning Java. I'm trying to add couple days to the GregorianCalendar but it doesn't work. Here... (Ignore the top chunk), its the adding dates at the bottom that is annoying. /* * Author:Matt M * Date:8.12.13 * Discription: When the user inputs the deadline, and the difficulity of the project, * the program gives the date he should start working on it */ import java.util.*; public class DeadlinePlanner{ public static void main(String[] args) { //take information and restart questions if information is wrong int month = 0, day = 0 ; do { do { System

adding days to a date

纵饮孤独 提交于 2019-11-30 18:50:30
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); System.out.println(sdf.format(startDate.getTime())); } public void today() { newDay = startDate.add(5, 1); System.out.println(newDay); //I want to add a day to the start day and when I start another new day, I want to add another day to that. } I am getting the error

Adding Days to Calendar

荒凉一梦 提交于 2019-11-30 16:59:54
问题 I'm new to this site and I have just started learning Java. I'm trying to add couple days to the GregorianCalendar but it doesn't work. Here... (Ignore the top chunk), its the adding dates at the bottom that is annoying. /* * Author:Matt M * Date:8.12.13 * Discription: When the user inputs the deadline, and the difficulity of the project, * the program gives the date he should start working on it */ import java.util.*; public class DeadlinePlanner{ public static void main(String[] args) { /

Converting a Gregorian date to Julian Day Count in Objective C

那年仲夏 提交于 2019-11-30 14:13:29
I need Objective C method for converting Gregorian date to Julian days same as this PHP method (GregorianToJD). According to http://en.wikipedia.org/wiki/Julian_day , the Julian day number for January 1, 2000, was 2,451,545. So you can compute the number of days between your date and this reference date. For example (Jan 1, 2014): NSUInteger julianDayFor01012000 = 2451545; NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; [cal setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; NSDateComponents *comp = [[NSDateComponents alloc] init]; comp.year = 2014;

Convert between calendars

蹲街弑〆低调 提交于 2019-11-30 12:37:01
How to convert between calendars? Here is what I have: UmAlQuraCalendar hijri = new UmAlQuraCalendar(); GregorianCalendar cal = new GregorianCalendar(); DateTime hijriDate = new DateTime(1434, 11, 23, hijri); DateTime gregorianDate = ...; // I need a gregorianDate that corresponds to the hijriDate . It seems that the Date saved in DateTime is always in the current calendar. So if the current calendar is Gregorian hijriDate is already in Gregorian. var hijriDate = new DateTime(1434, 11, 23, hijri); //Console writeline will show 2013-09-29 00:00:00 If your current calendar is UmAlQuraCalendar

java.lang.IllegalArgumentException: Bad class: class java.util.GregorianCalendar

落爺英雄遲暮 提交于 2019-11-30 10:43:22
I received this exception while using GregorianCalendar java.lang.IllegalArgumentException: Bad class: class java.util.GregorianCalendar Who know how to fix, Please help me. p/s : I used the following code : Calendar someDate = GregorianCalendar.getInstance(); someDate.add(Calendar.DAY_OF_YEAR, -7); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String formattedDate = dateFormat.format(someDate); UPDATED I should be use this line to achieve the date time : String formattedDate = dateFormat.format(someDate.getTime()); A Calendar can't be directly formatted, you need

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

懵懂的女人 提交于 2019-11-30 08:32:52
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 1 1/1 is week 1 8/1 is week 2 C# offers a GregorianCalendar class, that has a function GetWeekOfYear(date, rule, firstDayOfWeek) . The parameter rule is an enumeration with 3 possible values: FirstDay, FirstFourWeekDay, FirstFullWeek . From what I've understood I should