Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Datetimes in java (again)

Datetimes in java (again)

Scheduled Pinned Locked Moved The Weird and The Wonderful
javacomtoolsquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    V 0
    wrote on last edited by
    #1

    GregorianCalendar date = new GregorianCalendar(1888, 0, 1, 0, 0, 0);
    SimpleDateFormat sdf = new SimpleDateFormat("YYYY");
    String convertedstring = sdf.format(date.getTime());
    System.out.println(convertedstring);

    output: 1887 (on my laptop anayway)

    GregorianCalendar date = new GregorianCalendar(1888, 0, 1, 0, 0, 0);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
    String convertedstring = sdf.format(date.getTime());
    System.out.println(convertedstring);

    output: 1888 For those who didn't notice, in sample 1 I put "YYYY", in sample 2 "yyyy". I couldn’t immediately find something in the docs or google explaining this…

    V.
    (MQOTD Rules and previous Solutions )

    B 1 Reply Last reply
    0
    • V V 0

      GregorianCalendar date = new GregorianCalendar(1888, 0, 1, 0, 0, 0);
      SimpleDateFormat sdf = new SimpleDateFormat("YYYY");
      String convertedstring = sdf.format(date.getTime());
      System.out.println(convertedstring);

      output: 1887 (on my laptop anayway)

      GregorianCalendar date = new GregorianCalendar(1888, 0, 1, 0, 0, 0);
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
      String convertedstring = sdf.format(date.getTime());
      System.out.println(convertedstring);

      output: 1888 For those who didn't notice, in sample 1 I put "YYYY", in sample 2 "yyyy". I couldn’t immediately find something in the docs or google explaining this…

      V.
      (MQOTD Rules and previous Solutions )

      B Offline
      B Offline
      BotCar
      wrote on last edited by
      #2

      "YYYY" means week years.

      Quote:

      A week year is in sync with a WEEK_OF_YEAR cycle. All weeks between the first and last weeks (inclusive) have the same week year value. Therefore, the first and last days of a week year may have different calendar year values. For example, January 1, 1998 is a Thursday. If getFirstDayOfWeek() is MONDAY and getMinimalDaysInFirstWeek() is 4 (ISO 8601 standard compatible setting), then week 1 of 1998 starts on December 29, 1997, and ends on January 4, 1998. The week year is 1998 for the last three days of calendar year 1997. If, however, getFirstDayOfWeek() is SUNDAY, then week 1 of 1998 starts on January 4, 1998, and ends on January 10, 1998; the first three days of 1998 then are part of week 53 of 1997 and their week year is 1997

      SimpleDateFormat[^] GregorianCalendar[^]

      B 1 Reply Last reply
      0
      • B BotCar

        "YYYY" means week years.

        Quote:

        A week year is in sync with a WEEK_OF_YEAR cycle. All weeks between the first and last weeks (inclusive) have the same week year value. Therefore, the first and last days of a week year may have different calendar year values. For example, January 1, 1998 is a Thursday. If getFirstDayOfWeek() is MONDAY and getMinimalDaysInFirstWeek() is 4 (ISO 8601 standard compatible setting), then week 1 of 1998 starts on December 29, 1997, and ends on January 4, 1998. The week year is 1998 for the last three days of calendar year 1997. If, however, getFirstDayOfWeek() is SUNDAY, then week 1 of 1998 starts on January 4, 1998, and ends on January 10, 1998; the first three days of 1998 then are part of week 53 of 1997 and their week year is 1997

        SimpleDateFormat[^] GregorianCalendar[^]

        B Offline
        B Offline
        Brisingr Aerowing
        wrote on last edited by
        #3

        :confused: Quite odd, that is.

        Gryphons Are Awesome! ‮Gryphons Are Awesome!‬

        R 1 Reply Last reply
        0
        • B Brisingr Aerowing

          :confused: Quite odd, that is.

          Gryphons Are Awesome! ‮Gryphons Are Awesome!‬

          R Offline
          R Offline
          Rob Grainger
          wrote on last edited by
          #4

          Unfortunately, many human systems for dealing with dates are odd, all computers can do is reflect that.

          "If you don't fail at least 90 percent of the time, you're not aiming high enough." Alan Kay.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups