GregorianCalendar adding year and month

Hi all

I am trying to create a package using Gregorian calendar where I expect a result comparable to 20101029 (YYYYMMDD)

So I created a code

/ code

package com.cera.hyperionUtils;
Import Java.util;

public class HypDate {}

public static int yearmonthday (Field1 int)
{
1 declare the calendar
Calendar c = new GregorianCalendar();
c.setLenient (true);

2 perform operations
3. extract and return the result
int = Calendar.YEAR field * 10000 + Calendar.MONTH * 100 + Calendar.DAY_OF_MONTH;
Return c.get (field);
}

Public Shared Sub main (String [] args)
{
System.out.println (HypDate.yearmonthday (1));

}
}

/ code

But then it gives me an error.

Can someone help me with this?

Published by: Madeleine Kattookaran, 28 October 2010 13:23

1. in the validation of code, surround with [code] and [/ code] (without the spaces within the brackets). Use the Preview tab to view the appearance before submitting your message.

2. you must be precise, complete and clear in your requirements. It is difficult for people who will help you if you their capture.

It is not really clear what you mean by "add an option where the user can choose. Do you mean they get specify everything they want? Or you're going to give them a selection of a few to choose? In one case, I don't see where is the problem. If you know how to use SimpleDateFormat with a specific format string, then you know how to use it with other institutions.

Obviously, you will have to change

public static final String DATE_FORMAT_NOW = "yyyyMMdd";

something which sets the string format correctly when it is selected or entered.

Tags: Java

Similar Questions

  • Time of year and month to generate

    Hello

    How can I generate years and months certain period, by using a single query

    Example: I would like to generate every month between 2010 and 2012, it shows

    201001

    201002

    ...

    ..

    201012

    201101

    201102

    ..

    201112

    201201

    201202

    201203

    ....

    ....

    201212

    How can I make using query without using cursor?

    TIA

    using

    Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production

    PL/SQL Release 11.2.0.4.0 - Production

    CORE Production 11.2.0.4.0

    AMT for Linux: Version 11.2.0.4.0 - Production

    NLSRTL Version 11.2.0.4.0 - Production

    So, technically... you always use a cursor.

    Select add_months (date ' 2010-01-01', rownum-1)

    OF the double

    connect add_months (date ' 2010-01-01', rownum-1)<= date="">

    /

    would give you a start every day of a month of 01/2010 to 12/2012 as a DATE!

    HTH

  • How to filter the blog by year and month not only? Please help ASAP!

    Hey everybody!

    Does anyone know any code so that I can filter by year in the catalyst for business blog feature? at the moment I can do only a month.

    Quick help would be greatly appreciated!

    Thank you!

    James

    Hi James,

    Are you talking about so there blog post filtering filtered by year?

    If so I suggest to create tags for 'years' and then assign the ticket to blog as a result.

    Once completed, it will appear like this on the front-end server in your overall layout of blog.

    I hope this helps!

    -Sidney

  • Extract data based on the year and month

    My clients have taken a field TimeStamp DB Oracle and downloaded the access in a TEXT field format.
    Samples: 20060401001348CS

    Everything I'm doing is extracted from the data based on the year and the month. I equal to 200604 *, 200604%. Have also tried to use AS.
    Nothing works. It may just be that dificult. Help, please. Thank you

    Mike

    I'm SO sorry. I have 35 years of Experinece in this area and I have my data (assuming) was all a 200604 date and he was not. The query did work. I'll have more questions and that you do not want to loose credability with this site. Again, I am sorry. Sincere to help thanks.
    Ron

  • I have problems with D4.1 in Labview ' 09. It is said to determine the age of a person in years, when given the month in course, day, and year and month of birth of the person, day, and year

    Seen someone's birth month day and year... and also the day of the current month and year like entries... calculate their age, years... as output... age should not increment by one until the arrival of their birthday this year.   I can't get the coding right... Please help


  • Count the days back by year and month?

    In my doc, I have 7 text fields (Sun, Mon, Mar, sea, game, Fri, SAT). I use another field enter a date. When I enter an end date, I have 7 fields to be filled with dates. For example, if I enter the date field 06 18, 2016, I wish I had the 7 fields like this, Sun would show 12, Lun would show 13, AUT show 14, sea would indicate 15, game show 16, Fri would show 17 and Sam would have 18. I'm counting the days is backwards because I'm coming the weekend of date (always a Saturday).

    What I'm running is the month before sometimes will have 30 days, some months have 31 (and of course leap years). Thus, for example, if I choose 2 July 2016 days should come back like that, Sun should see 26, LUNs should show 27, Tue should show 28, sea should show 29, that game should show 30, Fri should show 01, Sam should show July 02.

    How can I do this correctly? I need a javascript smart thing to do. Can someone please help me with an example? Thank you.

    Here is a link to a sample form that shows how you can do this: http://acroscript.net/pdf/demos/populateWeek.pdf

    The script is located in the field Validate event entry date. Note that day fields use a special naming convention that allows a simplification of the code, so you have to use a similar model.

  • How to get the year and month of a whole year

    Hello

    I have a list of selection and when the user selects the list values are like this 201101,201102,201103

    I tried like this


    declare
    T_DATE varchar2 (25);
    Start
    because me in 1.12 loop
    Select TO_CHAR (ADD_MONTHS (SYSDATE, + 1), "YYYYMM") in the double T_DATE;
    dbms_output.put_line (V_DATE);
    end loop;
    end;

    But its bad and I can not get clear idea where to change the code

    Thanks and greetings
    Srikkanth.M

    Srikkanth.M wrote:
    Hello

    I have a list of selection and when the user selects the list values are like this 201101,201102,201103

    If you want to list for the current year from Jan 201101,201102, 201103... 201112, then try this

    DECLARE
      v_Date  VARCHAR2(25);
      n_month NUMBER;
    BEGIN
      SELECT extract (MONTH FROM sysdate) INTO n_month FROM dual;
      FOR i IN 1..12
      LOOP
        SELECT TO_CHAR(ADD_MONTHS(SYSDATE, (i-n_month)), 'YYYYMM')
        INTO v_date
        FROM dual;
        dbms_output.put_line(v_date);
      END LOOP;
    END;
    

    Vivek L

  • partitioning in 11g by year and month

    Hello

    I use oracle 11g and oracle 9i database data migration.
    9i has given since 2001 until 2010 Leave a how about every year will be 12 million records, monthly around 1 M

    11 g, must now create this annual partion table from 2001 to 2009
    and since 2010 Jan leave the partition should be monthly and is expected to grow automatically.

    How do I create partion table annual (2001 to 2009) and a monthly interval partion (2010 Jan go and grow) in 11g?

    Here is the sample table for an eg..
    
    
    -- this is for 2010
    create table sales
    (
       sales_id    number,
       sales_dt    date
    )
    partition by range (sales_dt)
    interval (numtoyminterval(1,'MONTH'))
    (
       partition p001 values less than (to_date('2010-02-01','yyyy-mm-dd'))
       partition p002 values less than (to_date('2010-03-01','yyyy-mm-dd'))
    );

    In fact, it should be:

    create table sales
    (
       sales_id    number,
       sales_dt    date
    )
    partition by range (sales_dt)
    interval (numtoyminterval(1,'MONTH'))
    (
       partition p001 values less than (date '2002-01-01'),
       partition p002 values less than (date '2003-01-01'),
       partition p003 values less than (date '2004-01-01'),
       partition p004 values less than (date '2005-01-01'),
       partition p005 values less than (date '2006-01-01'),
       partition p006 values less than (date '2007-01-01'),
       partition p007 values less than (date '2008-01-01'),
       partition p008 values less than (date '2009-01-01'),
       partition p009 values less than (date '2010-01-01')
    )
    /
    

    SY.

  • Year and month display

    Hello

    I need display the date format MONTH-YYYY in a SQL query, the query Condition is like that

    If I run the query today it should show from May to November 2012 (IE interval of 6 months)

    If I run the same question next month must show Jun-2012 December 2012 (IE interval of 6 months)

    Based on the date system, should it complete the date rate please suggest me how to get these date ranges.

    Thank you
    Sudhir
    /* Formatted on 2012/05/22 15:02 (Formatter Plus v4.8.8) */
    SELECT TO_CHAR (SYSDATE, 'MON RRRR'), TO_CHAR (ADD_MONTHS (SYSDATE, 6), 'MON RRRR')
      FROM DUAL;
    
  • can you help to reset the iPhone 6 +? used of the year and the month. Now, when you update, it asks activation and I can't remember anything! Arouca and verification is in stock

    can you help to reset the iPhone 6 +? used of the year and the month. Now, when you update, it asks activation and I can't remember anything! Arouca and verification is in stock

    To activate you need your Apple ID and password. If you forgot their date on https://iforgot.apple.com.

  • Why my display of the date of the mailbox does not have a / between the year and the month?

    I'm talking here about how the date of different e-mails appear in my Inbox. I have a / between the month and the day, and a / after the day, but I did not / between the year and the month.

    TB uses the date format short, such that defined by your operating system, which, in the case of Windows, is located in the Panel control/region and language.

    http://KB.mozillazine.org/Date_display_format

    There are a few modules that might also be useful:

    https://addons.Mozilla.org/en-us/Thunderbird/addon/ConfigDate/

    https://addons.Mozilla.org/en-us/Thunderbird/addon/Super-date-format/

    http://chrisramsden.vfast.co.UK/3_How_to_install_Add-ons_in_Thunderbird.html

  • I got a virus last year and tried to remove it for months, it's a virus IMPOSSIBLE!

    : Origin IMPOSSIBLE the virus!

    I got a virus last year and tried to remove it for months had to leave and walk away to keep my sanity! VAIO and OS is vista!

    I get a BSOD and only able to boot in safe mode!

    It only doesn't let me do a system restore (even command line)

    I run rkill it finds nothing...

    EACH SPY software removal

    I went through tons to fix!

    I would LIKE a RESPONSE or any kind of help! I miss my laptop!

    Hello

    Run everything first is that there is no rootkits that can survive a re-installation of Windows.

    TDSSKiller.exe. - Download the desktop - so go ahead and right-click on it - RUN AS ADMIN
    It will show infections in the report after the execution.
    http://support.Kaspersky.com/viruses/solutions?QID=208280684

    Check with Sony support for the methods to restore the laptop back to the form of the plant which removes
    all programs and data, save the data off the computer and get ready to re - install the
    programs.

    Sony - Contacts
    http://eSupport.Sony.com/us/Perl/contact-land.pl

    Sony - drivers
    http://eSupport.Sony.com/Perl/select-System.pl

    Sony - Support
    http://eSupport.Sony.com/

    Sony - Forum
    https://Forum.sel.Sony.com/?XID=M:Showcase:eSupport

    I hope this helps and happy holidays!

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle=""><- mark="" twain="" said="" it="">

  • My license stops on 3 oct. I didn't want another year and remove Photoshop CC. stupid I know, but now I want to start in October, but I don't know how Adobe to know I want to pick up Adobe Creative cloud approx. PS and LR 12.09 each month

    My license stops on 3 oct. I didn't want another year and remove Photoshop CC. stupid I know, but now I want to start in October, but I don't know how Adobe to know I want to pick up Adobe Creative cloud approx. PS and LR 12.09 each month

    Go to your account and extend your subscription, Adobe ID

    reinstall your cc desktop application, https://creative.adobe.com/products/creative-cloud and use it to install your ps and lr

    [left the show Creative cloud download &install]

  • Can I organize pictures by year, then month, then the location. In the photo on my iPhone app, they are organized in this way and I would do the same in Lightroom. Is this possible?

    Can I organize pictures by year, then month, then the location. In the photo on my iPhone app, they are organized in this way and I would do the same in Lightroom. Is this possible?

    Find pictures of calendar is integrated into Lightroom. The filter bar allows you to find photos taken during the year, or any month/year or month/day/year. No work necessary to implement. Just use the filter bar.

    Location is also a means of organizing in Lightroom and is especially easy if your phone adds GPS coordinates to the pictures it takes. Even if the phone does not add the GPS location, you can do it manually in Lightroom.

  • I bought the Photoshop product for a year and spent a month and my product does not work.

    I bought the Photoshop product for a year and spent a month and my product does not work. reason why its not not a money from my card? I wrote the details of two my maps. It is played automatically? I hope I could understand my problem to you. Thank you!

    During the work week...

    To the link below, click on the still need help? option in the blue box below and choose the option to chat or by phone...

    Make sure that you are logged on the Adobe site, having cookies enabled, clearing your cookie cache.  If it fails to connect, try to use another browser.

    Creative cloud support (all creative cloud customer service problems)

    http://helpx.Adobe.com/x-productkb/global/service-CCM.html ( http://adobe.ly/19llvMN )

Maybe you are looking for

  • Install Firefox 32 and 34 do not sync even in a clean

    I have been using Firefox Sync since it was an armor called extension and it has worked perfectly so far. I used Firefox on Ubuntu 14.04 Aurora, but I had to uninstall Ubuntu completely from my computer and install Windows 7. The point is that on Win

  • Select the list box file and read the data from file

    I can list the files in the folder in the listbox 1. I want to just list file .txt files 2. How can I read data from the selected file (.txt)?

  • Trojan horse: J/SBlacoleRefC

    I use Windows XP and recently downloaded an email with the Trojan horse that above. The Trojan horse was only partially deleted with the Microsoft Safety Scanner. Does anyone know how to completely remove the malware. Your really Paul Lamprecht

  • Microsoft network adapter 03:54 works do not error code 31

    My home wireless network stopped working for no reason at all. I can still connect to the internet with my computer, but not with a wireless device in my house. All indications are that my modem is working properly. When I go into Device Manager, I h

  • How do I completely erase the hard drive and reinstall everything for Windows 7?

    I want to completely erase a hard drive on a laptop, that I intend to use when traveling. Then I install windows 7 (which I bought) and my other programs Can I get step by step please Thank you Wanda Gill