Questions tagged [gregorian-calendar]

The Gregorian calendar is the de facto international civil calendar.

more details can be found at: https://en.wikipedia.org/wiki/Gregorian_calendar

415 questions
251
votes
15 answers

How do I get the AM/PM value from a DateTime?

The code in question is below: public static string ChangePersianDate(DateTime dateTime) { System.Globalization.GregorianCalendar PC = new System.Globalization.GregorianCalendar(); PC.CalendarType =…
SilverLight
  • 19,668
  • 65
  • 192
  • 300
110
votes
7 answers

Simple conversion between java.util.Date and XMLGregorianCalendar

I'm looking for a simple method of converting between java.util.Date and javax.xml.datatype.XMLGregorianCalendar in both directions. Here is the code that I'm using now: import java.util.GregorianCalendar; import…
Jim Tough
  • 14,843
  • 23
  • 75
  • 96
64
votes
7 answers

How convert Gregorian date to Persian date?

I want to convert a custom Gregorian date to Persian date in C#. For example, i have a string with this contents: string GregorianDate = "Thursday, October 24, 2013"; Now i want to have: string PersianDate = پنج‌شنبه 2 آبان 1392 ; or string…
JAC
  • 950
  • 1
  • 7
  • 11
46
votes
2 answers

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

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 =…
Huy Tower
  • 7,769
  • 16
  • 61
  • 86
44
votes
2 answers

Getting current datetime using Calendar.getInstance() vs new GregorianCalendar()

What might be the difference between getting datetime using Calendar.getInstance() vs new GregorianCalendar() ?
Oh Chin Boon
  • 23,028
  • 51
  • 143
  • 215
34
votes
5 answers

Using GregorianCalendar with SimpleDateFormat

So, I've been racking my brain over this (should-be) simple exercise to make the program turn a date string into a GregorianCalendar object, format it, and return it again as a string when it's done. This is the last little bit of a program that…
31
votes
2 answers

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…
Kat
  • 678
  • 2
  • 11
  • 23
29
votes
7 answers

Displaying the last two digits of the current year in Java

How can I display only the last two digits of the current year without using any substring algorithms or any third party libraries? I have tried the below method and it gave a four-digit year. I want to know whether there are any date formatting…
нαƒєєz
  • 1,239
  • 4
  • 17
  • 27
27
votes
4 answers

Creating a GregorianCalendar instance from milliseconds

I have a certain time in milliseconds (in a Timestamp object) and I want to use it to create a GregorianCalendar object. How can I do that? EDIT: How do I do the reverse?
Amir Rachum
  • 76,817
  • 74
  • 166
  • 248
27
votes
5 answers

Specify the date format in XMLGregorianCalendar

I want to use a Date in XMLGregorianCalendar format for sending to a web service. The web service expects information in yyyy-dd-mm format. I use the below code to create an XMLGregorianCalendar and send it to web service. Date dob =…
Deepika
  • 455
  • 1
  • 4
  • 10
27
votes
6 answers

Getting current Year and Month resulting strange results

I am working on a learning project related to Android. I am trying to get current year & month by using below code but it not works for me. GregorianCalendar gc = new GregorianCalendar(); gc.YEAR // returning 1 gc.MONTH // returning…
Yaqub Ahmad
  • 27,569
  • 23
  • 102
  • 149
26
votes
3 answers

How can I get a Date from my Calendar?

I have a Map containing the birthdate of a person as a GregorianCalendar. For example: { motherEmailID=null, coreType=Ticket, _NULL=null, additionalFaclitiesProvided=[], dateOfBirth=java.util.GregorianCalendar[ …
Twity
  • 367
  • 1
  • 4
  • 11
22
votes
5 answers

Converting Gregorian date to Hijri date

How do you convert Gregorian dates to Islamic Hijri dates using JavaScript?
FuNk
  • 223
  • 1
  • 2
  • 6
21
votes
4 answers

How do I convert a java.sql.Date object into a GregorianCalendar?

I thought I'd be able to create a GregorianCalendar using the constructor that takes the year, month, and day, but I can't reliably get those fields from an instance of the java.sql.Date class. The methods that get those values from java.sql.Date…
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
21
votes
3 answers

Get day of the week from GregorianCalendar

I have a date and I need to know the day of the week, so I used a GregorianCalendar object but I get back some dates that are incorrect. GregorianCalendar calendar = new GregorianCalendar(year, month, day); int i =…
MataMix
  • 3,276
  • 10
  • 39
  • 58
1
2 3
27 28