Date format to get week result

Dear all
i had one question for date API need to ask someone else,
how can i convert the Date to week for example
the result if like this
3    |      4    |    5      | 6       | 7
08/20 08/21 08/22 08/23 08/24 what is the java API i can use to calculate in this month how many week it is
?

Hi thank everybody
i found one sample of this question and i could get current month my date in Calendar this function , but i need to calculate the whole week day in my output when i use for loop to plus 1 in Calendar.DAY_OF_MONTH it wasnot work currently , i would please need someone help me up this problem
thank
import java.util.Calendar;
public class CalendarDemo {
     public static void main(String[] args) {
          Calendar rightNow = Calendar.getInstance();
          int save[]     = new int[10];
        System.out.println("CurrentDT:");
        System.out.println("Year:" +
                   rightNow.get(Calendar.YEAR));
        System.out.println("Month:" +
                   getChineseMonth(rightNow));
        for(int i =0; i < 7; i++){
        System.out.println("Date&#65306;" +
                   rightNow.get(Calendar.DAY_OF_MONTH+i));
        System.out.println("Week&#65306;" +
                   getChineseDayOfWeek(rightNow));
    public static String getChineseMonth(Calendar rightNow) {
        String chineseMonth = null;
        switch(rightNow.get(Calendar.MONTH)) {
            case Calendar.JANUARY:
                chineseMonth = "1";
                break;
            case Calendar.FEBRUARY:
                chineseMonth = "2";
                break;
            case Calendar.MARCH:
                chineseMonth = "3";
                break;
            case Calendar.APRIL:
                chineseMonth = "4";
                break;
            case Calendar.MAY:
                chineseMonth = "5";
                break;
            case Calendar.JUNE:
                chineseMonth = "6";
                break;
            case Calendar.JULY:
                chineseMonth = "7";
                break;
            case Calendar.AUGUST:
                chineseMonth = "8";
                break;
            case Calendar.SEPTEMBER:
                chineseMonth = "9";
                break;
            case Calendar.OCTOBER:
                chineseMonth = "10";
                break;
            case Calendar.NOVEMBER:
                chineseMonth = "11";
                break;
            case Calendar.DECEMBER:
                chineseMonth = "12";
                break;               
        return chineseMonth;
    public static String getChineseDayOfWeek(
                                 Calendar rightNow) {
        String chineseDayOfWeek = null;
        switch(rightNow.get(Calendar.DAY_OF_WEEK)) {
            case Calendar.SUNDAY:
                chineseDayOfWeek = "7";
                break;
            case Calendar.MONDAY:
                chineseDayOfWeek = "1";
                break;
            case Calendar.TUESDAY:
                chineseDayOfWeek = "2";
                break;
            case Calendar.WEDNESDAY:
                chineseDayOfWeek = "3";
                break;
            case Calendar.THURSDAY:
                chineseDayOfWeek = "4";
                break;
            case Calendar.FRIDAY:
                chineseDayOfWeek = "5";
                break;
            case Calendar.SATURDAY:
                chineseDayOfWeek = "6";
                break;          
        return chineseDayOfWeek;
}

Similar Messages

  • Problem with data format when getting from a database

    I'm trying to get a date from the database but the problem is that it also return the time. I have tried to change the format of the date when retrived from my database but it still returns the time.
    Any solutions?
    String theDBDate = rset.getString("date_of_call");
    SimpleDateFormat formatterdate = new SimpleDateFormat ("EEE, MMM d, ''yy");
    String date = formatterdate.format(theDBDate);
    theCalls.setDateofCall(date);// callin my Call Class to store the date which is a string

    Hi could any help me? I have this problem for the last few day. I gave up on it for a while but today I'm trying to get to the botton of this problem.
    I connecting to an oracle database but it return back the date & time but I want only the date.
    Here my code.
    Locale currentLocale= new Locale("en","GB");
    Date today = new Date();
    DateFormat formatter = DateFormat.getDateInstance(DateFormat.DATE_FIELD,currentLocale);
    String theSQL = (" Select * From Call ") ;
    Statement stmt;
    stmt = conn.createStatement();
    ArrayList CallsList = new ArrayList();
    ResultSet rset;
    rset = stmt.executeQuery(theSQL);
    while(rset.next() == true)
    Call theCalls = new Call();
    theCalls.setCallNo(rset.getInt("call_no"));
    theCalls.setUsername(rset.getString("username"));
    theCalls.setCompID(rset.getString("comp_id"));
    theCalls.setTimeofCall(rset.getString("time_of_call"));
    Date todaydate = rset.getDate("date_of_call");
    Timestamp theDBDate = rset.getTimestamp("date_of_call");
    SimpleDateFormat formatterdate = new SimpleDateFormat ("EEE, MMM d, ''yy");
    String date = formatterdate.format(theDBDate);
    theCalls.setDateofCall(date);
    theCalls.setPriorty(rset.getString("priorty"));
    theCalls.setProbCat(rset.getString("problem_cat"));
    theCalls.setProbDesc(rset.getString("problem_desc"));
    theCalls.setCloseDate(rset.getString("close_date"));
    theCalls.setProbSol(rset.getString("problem_sol"));
    theCalls.setStatus(rset.getString("status"));
    theCalls.setAssign(rset.getString("assign"));
    CallsList.add(theCalls);
    conn.close();
    return CallsList;

  • Date format when getting a PDF document with RESTful changes

    Hi all,
    I have a simple document with a date concatenation (as a string) for DateFrom - DateTo (for example "1/4/2015 - 30/4/2015")
    When I am in WebI I can see it in this format, even if I export it to PDF or Excel.
    However when I open it using BO BI 4.1 SDK RESTful in PDF or Excel, the date changes to "American format" like this : "4/1/2015 - 4/30/2015"
    Is there a way to avoid this, either as an option/parameter in the RESTful call or in the configuration of the BI server?
    Thanks

    Hello Enrique,
    Are you using the same user in Webi vs REST? I ask because the locale used is the PVL (prefered viewing locale) one.
    You can override the locale using a http header : X-SAP-PVL. But, you have to be very careful because you have to set the same header value in subsequent RESTful calls.
    Indeed, internally, we handle one document instance for each used locale.
    Regards,
    Anthony

  • Problem with data format while getting data from BI

    Hi,
    I am trying to build a universe for the development of Web I reports, the data source on which I am trying to build the universe is from BI.
    There is date field in the data, which is loaded in to BI as a date, but while I am building the universe over the cube I am getting it as a character.
    When I am trying to use that field in the Web I reports, I have a problem sorting the date column.

    hi ,
    when you run the webi report , click change query and in that go to yourt field properties and then chage its settings to date.
    I think I have done this of similar kind lontg back. But there is this property somewhere where we can change the type of the varaible and then you can see the expected resutls.
    Thanks ,
    Anjna

  • Question about get web service result in actionscript and convert data format

    Hi, All
    I have question about how to get dataset from web services
    and put it in tree structure. I have 2 questions about this:
    1, How can I get data correctly in actionscript?
    I have no problem to get data by
    <mx:ArrayCollection id="acFolder"
    source="{mx.utils.ArrayUtil.toArray(MyGServices.getFolder.lastResult)}"
    />
    And display in datagrid.
    But when I try to use
    public function
    handleFolderContents(event:mx.rpc.events.ResultEvent):void{
    arData=mx.utils.ArrayUtil.toArray(event.result);
    acData=new ArrayCollection(arData);
    input.text=acData.getItemAt(0).id;
    Seems I can’t get data, it always say:
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    2, how to convert data format
    I get data from web service and want to convert it to tree
    structure, as mention below:
    I get:
    <Array>
    <id>111</id>
    <Name>Production1</Name>
    </Array>
    <Array>
    <id>222</id>
    <Name>Production2</Name>
    </Array>
    Convert to:
    <mx:XMLList id="treeData">
    <node>
    <node label="Production1" data="111">
    <node label="Production2" data="222"/>
    </node>
    </node>
    </mx:XMLList>
    Please help me.
    Thanks.

    First, don't specify the package path in the argument
    declaration. Instead import the event object:
    import mx.rpc.events.ResultEvent;
    The docs state this emphatically.
    Second, try "lastResult", in place of "result":
    arData=mx.utils.ArrayUtil.toArray(event.lastResult); // I am
    not positive about this. I maybe recall reading that result was ok
    for the event object, but maybe not.
    Finally, why do you want to convert the xml? You certainly
    could, but it would be a manual process, recursively reading the
    existing xml nodes and building the new structure, but again, why?
    Just use a labelFunction if necessary to display the nodes as
    you wish.
    Tracy

  • Data Wrap and data Format in OBIEE Reports

    Hi
    When we select few columns , the data is getting wrapped. To avoid this we had chosen "Plain Text (Without broken spaces)" available in the data format tab and it resulted in unwrapped data.But we are unable to get the same format as that of database.
    Please , suggest us how can we get the same dataformat for the columns similar to the database format in reports .
    Thanks.

    Hi
    Our requirement is not to display multiple column values in the same cell in OBIEE .
    As mentioned earlier we do have a column named " Comments" . This column in database contains the data in the following format :
    - Statement 1
    - Statement 2
    - Statement 3
    - Statement 4
    FOLLOW-UP:
    - Statement 5
    - Statement 6.
    - Statement 7
    Now when we create a report with this column , the data for this column in the report is as follows :
    - Statement 1 - Statement 2 - Statement 3 - Statement 4 FOLLOW-UP: - Statement 5 - Statement 6 - Statement 7 .
    But we do have a requirement where the dataformat for this column in the report should be same as that of the database ie., the data displayed under this column in the report should be same as it is in database as follows :
    - Statement 1
    - Statement 2
    - Statement 3
    - Statement 4
    FOLLOW-UP:
    - Statement 5
    - Statement 6.
    - Statement 7
    BUT NOT AS
    - Statement 1 - Statement 2 - Statement 3 - Statement 4 FOLLOW-UP: - Statement 5 - Statement 6 - Statement 7 .
    Thanks.

  • Need to convert into date format

    Hi all,
    I need to convert '2008-11-26T11:07:38-06:00' [YYYY]-[MM]-[DD]T[HH]:[MM]:[SS][TIMEZONE]
    in format 'YYYY-MM-DD HH:MM:SS'.
    Thanks in advance.

    >
    Thank you for your reply
    But it is giving me output as '26-NOV-08'
    And I want in format '2008-11-26 07:38' i.e 'YYYY-MM-DD HH:MM'.
    >
    Then you are not looking for a date, You are looking for a string.
    The date format that gets displayed is dependent on nls_date_format parameter.
    If you want a string in the format you asked, then,
    SELECT TO_CHAR ( TO_DATE ( '2008-11-26T11:07:38-06:00', 'YYYY-MM-DD"T"HH24:MI:SS"-06:00"'), 'YYYY-MM-DD HH24:MM:SS')
      FROM DUAL;Or if you just want the date to be displayed like that then
    Do,
    SQL> alter session set nls_date_Format="YYYY-MM-DD HH24:MI:SS";
    Session altered.
    SQL> SELECT TO_DATE ( '2008-11-26T11:07:38-06:00', 'YYYY-MM-DD"T"HH24:MI:SS"-06:00"') dt
      2    FROM DUAL;
    DT
    2008-11-26 11:07:38
    SQL> G.

  • Date format problem in web dynpro java

    Currently, the date format that gets displayed in our webdynpro java application is MMDDYYYY...i am assuming this is because the web dynpro application has language resource set to en_US as its Current locale in the web dynpro deployed content section.  Howver i want it to display as DDMMYYYY. I have changed the default properties in visual admin for web dynpro from en to en_GB however this has no impact what so ever as the current locale is always set to en_US even after the change so am wondering this property is hidden some where else.  Now the web dynpro i am talking about is a adobe portal application. Could you give me any pointers as to where else i can look for or how i can change the current locale properly ??
    Regards
    Kal

    The date format in the Web Dynpro Java Application depends upon locale. At runtime WDJ will do the following process to get the current locale for the date format to be determined.
    1. First the WDJ Application will check for the locale set for the user in UME.
    2. If there is no default locale in UME, then the it will check for the locale in the in the browser which in most cases by default is en-us.
    3. If not, then it will check for the sap.systemLocale in the Propertysheet default of Visual Admin
    4. If there no locale specified in Visual Admin, itu2019s taken from the WAS JVM
    Please check the below SAP Note
    http://help.sap.com/saphelp_nw04/helpdata/en/a0/58db515b95b64181ef0552dc1f5c50/frameset.htm
    Regards,
    Chandran S

  • Date format problem in webdynpro java

    Currently, the date format that gets displayed in our webdynpro java application is MMDDYYYY...i am assuming this is because the web dynpro application has language resource set to en_US as its Current locale in the web dynpro deployed content section.  Howver i want it to display as DDMMYYYY. I have changed the default properties in visual admin for web dynpro from en to en_GB however this has no impact what so ever as the current locale is always set to en_US even after the change so am wondering this property is hidden some where else.  Now the web dynpro i am talking about is a adobe portal application. Could you give me any pointers as to where else i can look for or how i can change the current locale properly ??
    Regards
    Kalyan

    Hi.
    Also this link could help you.
    http://help.sap.com/saphelp_nw04s/helpdata/en/18/f3674039c6c549e10000000a1550b0/content.htm
    In special the table showing the order the locale is set in the web dynrpo application.
    Also it is shown in the last pages of this document, [Web Dynpro for Experts|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/58a7e390-0201-0010-abb1-8eec7eb7a2ec?quicklink=events&overridelayout=true].
    And finally you may use the sap.locale request parameter, how it's defined [here|http://help.sap.com/saphelp_nw04/helpdata/en/f4/651741f163f023e10000000a155106/frameset.htm]. You must add ?sap-locale=en_GB to url.
    Manuel Loayza.

  • To accept all date formats for variables

    Hi,
    I am getting a vadidation message on refresh of a query on entering European date format in the selection criteria "Please enter value in permitted format for variable XXXX"
    I need date to accept all date formats for variables to execute query.
    Currently US date format has been accomodated, On entering European date format i get the above validation message.
    Please suggest how do i supress this validation message or any other thoughts on the same.
    If anyone experienced the same before or applied any notes plz send the SAP Note number for the same. I am currently on BW 3.5.
    Message was edited by:
            tyson m

    tyson,
    why dont you control the date display through the user creation / user details option - then your date entries should sort themselves out.
    Arun

  • Cisco ISE Date Format mm/dd/yyyy

    We have implemented Cisco ISE Guest Portal and when we create a new account for a visitor the date format is mm/dd/yyyy.See attached file.
    We have tried to change it through Administration/Settings/Language Template/English/Configure Time/Date Formats unfortunately with no results.
    Is this a bug or i am not looking in the right place?
    We are running Cisco ISE 1.2.

    check CSCuj86793

  • Error in date format while downloading it into excel

    Hi Experts,
    I created a report and when i download date from report to excel the date format is getting reversed.
    FOR example   Date in REPORT : 07//2010
                                        IN EXCEL: 201007
    Kindly give some idea to resolve this issue.
    Regards,
    Vishwa

    hello,
    Please change the data type of date field to Character (C).
    and pass the required date value.
    It shouldl make correct output to excel...
    Thanks.

  • How to get year format result on date format in Bex

    Hi,
    I have requirement to display only year and month in seperate rows as a result in Bex.
    I have created on date field like MM/DD/YYYY and i have to display in two seperate rows as MM/YYYY and YYYY.
    Could anyone please suggest me how i can display these format in Bex.
    thanks in advance.

    Hi Prashant
    Regional settings of Windows are used to dispaly Date format in Bex reports.
    you neesd to change the settings in Regional settings:
    Control Panel-> Regional settings
    this will change to the desired Date format.
    Regards
    Vivek Tripathi

  • Date - how to get the number of the week

    I have a Date - string - w/e can be convered thats not the problem
    but how do I get the number of the week cuz the database holds events per week so I need to know the number of the week.
    I tried going true the api but I failed to find the right fuction, aldoh I recall seeing it somewhere a while ago.
    anyways got a deathline so easy dukies, first come first serve.

    how's this then?int weekOfYear = 0;
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); //your String format
    Date date = null;
    String dateString = "2003/06/16";
    try {
      date = sdf.parse(dateString);
    } catch (ParseException pe) {
      //hande bad date format
    if (date != null) {
      GregorianCalendar calendar = new GregorianCalendar();
      calendar.setTime(date);
      weekOfYear = calendar.get(Calendar.WEEK_OF_YEAR);
    Warning: Be careful of your locale settings when using week of year, you may need to investigate setFirstDayOfWeek(int value) and setMinimalDaysInFirstWeek(int value) to ensure you get the results you expect.

  • How to get week starting with sunday date

    Hi
    I have a date column "start_date", i need to create a report for all the weeks starting from sunday , for eg:
    i need to get week dates as :
    mm/dd/yy - 01/23/11 , 01/16/11 , 01/09/11 and so on...
    Please help
    Thanks...

    Hi,
    To find the last Sunday before or equal to start_date:
    SELECT     TRUNC ( start_date + 1
               , 'IW'
               ) - 1          AS week_start_date
    ...You can use an expression like this in a GROUP BY clause, also.
    This does not depend on you NLS settings. ISO weeks always start on Monday. Your week starts 1 day earlier, so that's why the expression above has the +1 and -1.
    (Depending on you NLS settings,
    SELECT     TRUNC ( start_date
               , 'D'
               )          AS week_start_date
    ...might do the same thing, but I still rocommend using 'IW'; a few extra keystrokes isn;t much to pay for a guarantee that it will always work.)
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.

Maybe you are looking for

  • Wide area coverage

    Morning All, I have a client that needs the coverage of a very big warehouse, and i have no idea if im suggesting the right solution. In this project i set 1 AP for each 250 square meters, but I have few bigger areas where I need a better solution, o

  • Any fm for PO Invoice receipt details ?

    Hi all, Is there any function which gives invoice receipt details for a purchase order ? I am aware of the tables to be used.

  • Disposition Area (MRP) in MM02 (BAPI_MATERIAL_SAVEDATA)

    Hi All, My mass upload program uses the FM BAPI_MATERIAL_SAVEDATA. Now I want to develope a mass upload program to create the disposition area of MRP. Q: Does someone know a FM or Global Class method that I can use for the mass upload program ?? Blac

  • Syntax Error in Test - Class Method

    Hello all, I've created a Class, and when I try to test one of the methods (from within SE24), I'm getting the following error:  "Syntax error in test.  Display generated test environment?" (When I say Yes, I'm taken to %_JJ_TESTFRAME_CLASS program)

  • Javascript:dosubmit  - error

    i have just build application.. and i don't know what happened every javascript:dosubmit button on page 1 give me an error look at picture http://img526.imageshack.us/img526/8498/47216945.jpg any suggestions? i can't build it again, please help :(