How to get the currrent month and year from a new date object

If I create a new Date object as "d",
java.util.Date d = new java.util.Date();how can I format the date to get the current Month as 'Jan' and the current year as '2008'. So if I have something like d.getMonth() gets the current month as 'Oct' and d.getYear() gets '2008'
Thanks,
Zub

[Read the flamin' manual you must. Hmm.|http://en.wikipedia.org/wiki/RTFM]
~~ Yoda.
Well no actually, he didn't say that, but he should have.
Cheers. Keith.
PS: Don't say that to a 7 foot pissedOff wookie when he's got his head stuck in a smoking hyperdrive, and you're being chased by a S-class battle cruiser... Ask Yoda how he got to be so short.
PPS: It is the SimpleDateFormat you seek ;-)
Edited by: corlettk on 14/10/2008 22:37 ~~ Also far to slow... but funny.

Similar Messages

  • How to get the previous month and year accordingly

    Hi friends,
    I wanted to select month as number like 4 and year as 2011
    but I want to select the previous month as of sysdate
    like if the sysdate is 10-jun-2011
    it should give me 5 as month and
    in the year it should give as 2011
    if the sysdate is 01-jan-2012
    the month should be as 12 and year should be as 2011
    thanks

    Hi,
    776317 wrote:
    thanks a lot I just dont need the 0 being prefixed... can you pls tell how to avoid that as well pls
    TO_CHAR ( ADD_MONTHS (SYSDATE, -1)
            , 'FMmm yyyy'
           )For details about how the FM modifier works, wee the SQL Language manual:
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/sql_elements004.htm#sthref456

  • How to get the week number of year from a Date object?

    Hi!
    I would like to know the week number of the year from a specified Date.
    I dont know how to set the first day of week, and set the minimum days of a week.
    I want to use Monday for first day of week, and at least 4 days of month in a week.
    For example if its 1st, January is Friday, then the first week starts on 4th, Monday.
    Anyone can help?

    Sorry. I should think before I move.
         public static int getWeekOfYear(Date date) {
             Calendar calendar = Calendar.getInstance();
             calendar.setTime(date);
             calendar.setFirstDayOfWeek(Calendar.MONDAY);
             calendar.setMinimalDaysInFirstWeek(4);
             return calendar.get(Calendar.WEEK_OF_YEAR);
         }

  • How to get the current month for a variable based on info object 0FISCPER3

    Hie Gurus
    I am working on the financial reports i am failing to derive the Current month from the variable based on infobject 0FISCPER3 PERIOD .
    I would also like to get the same month from the prevoius year. Any ideas?

    If I understood correctly, you need in your repot
    Current Month Plan This year || YTD Plan This Year || Current Month Plan Last Year || YTD Plan Last Year
    Your variable 0I_FISCPER3 must be on the object 0FISCPER3 which is nothing but just the Fiscal Period. This variable is a user entry mandatory Interval variable.
    if you are entering a range in the input screen for this variable, you will get cumulative values. If you just need to get the value for a month in first column your report, you will have to create another variable of type Customer Exit which will read the "To value" entered for the variable 0I_FISCPER3 and columns for Current Month should be restricted on this variable.
    if you are entering a single value in the selection screen of this variable, current month column should be restricted on this variable with "Equal To" operation and YTD colmns should be restricted to "Less Than Equal to" operator with this variable.
    0FISCPER3 just have posting period and not year, so you will have to use varialbes for 0FISCYEAR separately.
    Please let us know if it helps or if you are using some other variable based on 0FISCPER3 or 0FISCPER.
    Regards,
    Gaurav

  • How to get the server port and id from the Initialcontext

    hi
    i know that i can get the server port and id where the jndi service is listening from the InitialContext ( when i create InitialContext ic = new InitialContext(); from within a EJB. ). Does this work on any application server and where (at what position is for example the port) in the Enumeration at the ic are the different things put?

    I would usually just get the PROVIDER_URL property from the InitialContext and use that to determine the location of the naming service:
    String providerURL = (String)ic.getEnvironment().get(Context.PROVIDER_URL);You'll then need to parse that string to obtain the port and the server name. For example:
    // Assume that the provider URL is of form "protocol://server:port"
    int serverStartIndex = providerURL.indexOf("://" + 3);
    int serverEndIndex = providerURL.indexOf(:, serverStartIndex);
    String server = providerURL.substring(serverStartIndex, serverEndIndex);
    String port = providerURL.substring(serverEndIndex + 1);It's a fairly universal approach but there'll doubtlessly be some special cases (for example, the provider URL could be null and the InitialContextFactory class defaults it).
    You might have to adjust the server/port parsing stuff a bit as I just made that up and your URL might not conform to the pattern I described.
    Hope this helps.

  • How to get the programs (elements and premiere)from my old computer on my new PC?

    Can I get the programs from my old computer and use tham on my new (windows 8.1) computer?
    what do I do?

    I just did this so I hope I can remember.  I have a MAC so I went into my MAC hard drive and then library > application support > adobe > photoshop elements > 10 > creations > effects.  I selected all of my files and copied them.  I then went back to photoshop elements > 12 > creations and pasted the files into effects.  I then restarted PSE and all of my files were there! 

  • SAP Cloud for customer how to get the Account ID and UUID from cloud

    Hi Experts,
    I have small requirement in cloud for customer.
    How to get all the account id with UUID in excel sheet using any SDK or other ways?
    Any way to get this information because i have tried using "Mass Data Maintenance" but not getting any information. 
    anyone know how can i get this information in cloud system?
    Many thanks,
    Mithun

    Hi Mithun,
    In my understanding there SAP will not share IP address of tenant. If this is really urgent you should discuss to SAP Partner coach or any other representative. SAP network team will not directly communicate with you, this will require numerous approval inside SAP itself.
    Thanks
    Sunil Maurya

  • Problem to insert only month and year instead of full date

    select b.penjara_id, p.penj_lokasi, a.no_daftar, b.episod, b.nama1,to_char(a.trkh_mula_prl,'dd/mm/yyyy') as trkh_mula_prl, to_char(bulan_proses,'mm/yyyy') as bulan_proses,
            b.epd, b.lpd
    from prl_daftar_proses a, senarai_pesalah b, penjara p
    where a.no_daftar=b.no_daftar
    and a.episod=b.episod
    and b.penjara_id = p.penjara_id
    and a.setuju_jplp is null
    and a.bulan_proses between to_date(:FROM,'dd/mm/yyyy') and to_date(:TO,'dd/mm/yyyy')
    order by b.penjara_id, a.bulan_proses,a.no_daftarHi,anyone can help me how i can insert only month and year from the value that have full date in the database??
    for example,the date is 09/18/2012, but i just want to insert 09/2012 as parameter. If i want to insert only one parameter, i can do that..But i have problem when I want to insert two parameters..

    jeneesh wrote:
    Welcome to the forum..
    This..?
    Assuming bulan_proses is a date without time part
    select b.penjara_id, p.penj_lokasi, a.no_daftar, b.episod, b.nama1,to_char(a.trkh_mula_prl,'dd/mm/yyyy') as trkh_mula_prl, to_char(bulan_proses,'mm/yyyy') as bulan_proses,
            b.epd, b.lpd
    from prl_daftar_proses a, senarai_pesalah b, penjara p
    where a.no_daftar=b.no_daftar
    and a.episod=b.episod
    and b.penjara_id = p.penjara_id
    and a.setuju_jplp is null
    and a.bulan_proses between to_date(:FROM,'mm/yyyy') and last_day(to_date(:TO,'mm/yyyy'))
    order by b.penjara_id, a.bulan_proses,a.no_daftar
    i got another problem..
    before that.may i know what is the function of last_day?

  • How to get the current month value for a customer exit variable?

    How to get the current month value for a customer exit variable? 
    And also if we have an InfoObject with date value (including date, month, year), then how to derive the month value from this date type of Char.?
    Thanks!

    Hi Kevin,
    Check here........
    Re: Customer Exist for "From Current Date To Month End"
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/25d98cf6-0d01-0010-0e9b-edcd4597335a
    Cal month
    Regards,
    Vijay.

  • I want to accumulate rain for the day, month and year; What formula can I use?

    I want to accumulate rain for the day, month and year; What formula or expression can I use.
    I am using a Rain Wise product that converts pulses to an analog value.  The Rain Wise device can be
    set to measure up to 1", 5", or 10".  I will be setting the unit to 10 inches in increments of 0.01 inches.
    What I would like to do is everytime the signal increments I would like to count it as 0.01 then after reaching
    a period of time whether it be a day or a month reset back to zero.
    Need some advise on this problem.
    Solved!
    Go to Solution.

    Hello Ryan,
    Lookout gets a Modbus over Ethernet signal which originates as a 4-20mA input to a Moxa Ethernet I/O Module (E1240) in the field.  In Lookout I created a ModbusEthernet Driver and a tag which scales 0 - 65534 RAW to 0-10 Eng.  [0 - 10 is inches of rain]  Also, another piece of information is that after the rain gauge maxes out at 10 inches it will zero out and start over.
    I though the accumulator was time based and took a sample over a specific time period, for instance, one sample every 30 seconds then accumulate.  If this is so then if I have 5 inches of rain and then it stopped raining, then 30 seconds latter it would sample, it would see 5 inches and add that to be 10 inches when actually it had only rained 5 inches. 
    I really need some help with this process,
    David Lopez
    City of Corpus Christi

  • How to Get the current month at timezone UTC-10

    Hi All,
       can you please let me know How to Get the current month at timezone UTC-10.
    Function module ? which date and time needs to pass.

    Hi,
    Try with following code.
    DATA zdate TYPE  D.
    DATA ztime TYPE  T.
                      CALL FUNCTION 'ISU_DATE_TIME_CONVERT_TIMEZONE'
                        EXPORTING
                          x_date_utc          = sy-datum
                          x_time_utc          = sy-uzeit
                          x_timezone          = 'UTC-10'
                       IMPORTING
                         Y_DATE_LCL          = zdate
                         Y_TIME_LCL          = ztime
                       EXCEPTIONS
                         GENERAL_FAULT       = 1
                         OTHERS              = 2.
                      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                      ENDIF.
    WRITE : zdate, / ztime.
    Thank you,
    Sekhar.

  • Getting Day, month and year from Date object

    hello everybody,
    Date mydate = Resultset.getDate(indexField);
    Now i would like to get day, month and year from mydate.
    In another words, i'm looking for something equivalent to
    mydate.getDay() as this method is deprecated.
    Can somebody help me out please?
    Thank you in advance,

    swvc2000,
    Here is a sample class that demonstrates two ways in which to do this.import java.util.*;
    import java.text.*;
    public class DateSplitter {
       public static void main(String args[]) {
          /* even though your date is from a result set,
             pretend the following date is your date that
             you are using. The try catch block is used
             because I hand-crafted my date using
             SimpleDateFormat.  Substitute your date.*/
          Date yourDate = null;
          try {
             SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
             yourDate = formatter.parse("05/06/2000");
          } catch (ParseException e) { }
          //the following gets the current date
          Calendar c = Calendar.getInstance();
          //use the calendar object to set it to your date
          c.setTime(yourDate);
          //note months start at zero
          int month = c.get(Calendar.MONTH);
          int year = c.get(Calendar.YEAR);
          int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
          System.out.println("Calendar Month: "+month);
          System.out.println("Calendar Day: "+dayOfMonth);
          System.out.println("Calendar Year: "+year);
          System.out.println();
          /* Simple date format can also be used to strip them
             out of your date object.  When you use it, notice that
             months start at 1.  Also, it returns string values.  If
             you need integer values, you will have to use
             Integer.parseInt() as I did below.  If you are
             only concerned about the string values, just remove
             the Integer.parseInt part. */
          DateFormat formatter = new SimpleDateFormat("M");
          month = Integer.parseInt(formatter.format(yourDate));
          System.out.println("SDF Month: "+ month);
          formatter = new SimpleDateFormat("d");
          dayOfMonth = Integer.parseInt(formatter.format(yourDate));
          System.out.println("SDF Day: "+ dayOfMonth);
          formatter = new SimpleDateFormat("yyyy");
          year = Integer.parseInt(formatter.format(yourDate));
          System.out.println("SDF Year: "+ year);
       }//end main
    }//end DateSplitter classtajenkins

  • Get month and year from date type

    Hi all,
    I need to get the month and year from the date type.
    For example select to_date('2011-01-17', 'yyyy-mm-dd') from dual;Result needed:
    01-2011Any ideas?
    thanks in advance,
    Bahchevanov.

    Hello Bahchevanov,
    if you need the date to compute something, then you can
    TRUNC(SYSDATE,'mm')This will give you a date with the days removed -> 01.01.2011
    Regards
    Marcus

  • How to get the current month number

    Hi everyone,
    Does anybody know how to get the current month number in Oracle Discoverer Worksheet calculation?
    I try to use EUL_DATE_TRUNC(CURRENT_DATE, 'MM'), but instead I got 01-AUG-00.
    If I change the data display format to MM, it will give me "08" but if I use TO_NUMBER function to convert it to number I get error "invalid number"
    Is there anyway to get the current month value in number? Thanks

    Scott,
    Thank you so much! It works perfectly! :)
    Hope you have a great day ahead!
    Cheers,
    Angeline

  • How to get the current logged in username from windows and put it into an AS var

    Hello,
    I was hopeing someone would know how to get the current logged in username from windows and put it into a var, so I can create a dynamic text box to display it.
    Thanks in advance
    Michael

    Just for everyone’s info, this is the script I have used to get the logged in windows username into flash ---- not and air app.
    In the html page that publishes with the .swf file under the <head> section:-
    <script language="JavaScript" type="text/javascript">
    function findUserName() {
         var wshell=new ActiveXObject ("wscript.shell");
         var username=wshell.ExpandEnvironmentStrings("%username%");
         return username;
    </script>
    The ActionScript:-
    import flash.external.ExternalInterface;
    var username:String = ExternalInterface.call ("findUserName");
    trace (username); // a quick test to see it in output

Maybe you are looking for

  • Nokia Lumia 710 WP 7.8 Equalizer

    Do Nokia realy think that WP 7.8 owners will buy Nokia once more??? We use it not only for calling we also listen music, but its inpossible with 7.8, the sound is like from deep hole, that why we need equalizer!!!! Do it pls!!!

  • Default costcentre for gl codes

    Hi, my reauirement is default costcentre for gl codes. i was done configaration costcentre assign to gl codes in default assignment KA02, it is working on GL,AP,AR,AA but it is not work while creating the purchase requistion. can u give sugistion has

  • Switch iPod Classic from PC to a Mac

    Hi, I recently dowloaded ALL of my music/videos (nearly 33 GB) to my new 80GB Classic iPod using iTunes 7.5 on my Windows Vista. I am now getting rid of the Windows and switching over to a Mac. I know that I must reformat my iPod in order for it to c

  • Failed to start Admin Server for Weblogic Server Domain

    I Created a domain named mydomain in weblogic server 10.3 in server 2003.But when i start Admin Server for Weblogic Server Domain from startmenu, it failed. I examined the log under domains\mydomain\servers\AdminServer\logs\AdminServer.log and got th

  • Error 2131-So frustrated!

    Hello, I know this is a common question but I cannot seem to get anything to work. Help would be greatly appreciated. I am receiving the dreaded Error 2131 message when I try to burn a playlist to a CD, though it does the initialization fine. Here is