How to tanslate long integer to date format ?

import java.util.Date;
import java.text.*;
import java.io.*;
public class ex_date02 {
public static void main(String[] args) {
File fTimeOut = new File("template.java");
DateFormat defaultDate = DateFormat.getDateInstance();
System.out.println(defaultDate.format(new Date()));
DateFormat myformat = new SimpleDateFormat("yyyy/MM/dd HH:MM");
System.out.println(myformat.format(new Date()));
System.out.println(fTimeOut.lastModified());
}

Thank a lot
import java.util.Date;
import java.text.*;
import java.io.*;
public class ex_date02 {
public static void main(String[] args) {
File fTimeOut = new File("template.java");
DateFormat defaultDate = DateFormat.getDateInstance();
System.out.println(defaultDate.format(new Date()));
DateFormat myformat = new SimpleDateFormat("yyyy/MM/dd HH:MM");
System.out.println(myformat.format(new Date()));
System.out.println(fTimeOut.lastModified());
System.out.println(myformat.format (new Date (fTimeOut.lastModified())));
Output is
04-Feb-03
2003/02/04 01:02
1044337905000
2003/02/03 21:02

Similar Messages

  • Input Value long enough for date format ,Error in executing parallel query

    Hi,
    My Table: ANML( ID, STATUS,B_DATE,B_MONTH,B_YEAR, DEATH_DATE)
    status 1 for alive and 2 for dead.
    i wrote a view to get age.
    as
    create or relace view view1 as
    select top."ID",top."STATUS",top."DOB",top."DEATH_DATE",top."ANML_AGE",top."DAYSDIFF",
    CASE
    WHEN anml_age < 1
    THEN 'D'
    ELSE 'M'
    END age_unit,
    CASE
    WHEN anml_age < 1
    THEN TO_CHAR (daysdiff || ' Day(s)')
    WHEN anml_age < 12
    THEN TO_CHAR (anml_age || ' Month(s)')
    WHEN MOD (anml_age, 12) = 0
    THEN TO_CHAR (ROUND (anml_age / 12, 0) || ' Year(s) '
    ELSE TO_CHAR ( ROUND (anml_age / 12, 0)
    || ' Year(s) '
    || MOD (anml_age, 12)
    || ' Month(s)'
    END age_string
    from
    (SELECT a.*,
    CASE WHEN status IN ( 1)
    THEN FLOOR(MONTHS_BETWEEN(TRUNC(SYSDATE),dob))
    WHEN death_date IS NOT NULL AND status IN (2)
    THEN FLOOR(MONTHS_BETWEEN(death_date,dob))
    END anml_age,
    CASE WHEN status IN (1)
    THEN FLOOR(TRUNC(SYSDATE)-TRUNC(dob))
    WHEN death_date IS NOT NULL AND status IN (2)
    THEN FLOOR(TRUNC(death_date) - TRUNC(dob))
    END daysdiff
    from (
    SELECTanml.id, status,
    TO_DATE ( DECODE (b_date,
    NULL, 1,
    b_date
    || '-'
    || DECODE (b_month,
    NULL, 1,
    b_month
    || '-'
    || b_year,
    'dd-mm-yyyy'
    ) DOB,
    death_date
    FROM anml
    WHERE b_year IS NOT NULL
    ) a) top
    when i tried to fetch all values from view its working fine.
    But when i tried to fetch values based on condition like as follows,
    select * from view1 where anml_age > 20 and anml_age<30
    I am getting error like:
    Input Value long enough for date format and Error in executing parallel query
    Please tell me wht is wrong.

    Here is your formatted code
    create or relace view view1 as
    select top."ID",top."STATUS",top."DOB",top."DEATH_DATE",top."ANML_AGE",top."DAYSDIFF",
    CASE
    WHEN anml_age < 1
    THEN 'D'
    ELSE 'M'
    END age_unit,
    CASE
    WHEN anml_age < 1
    THEN TO_CHAR (daysdiff || ' Day(s)')
    WHEN anml_age < 12
    THEN TO_CHAR (anml_age || ' Month(s)')
    WHEN MOD (anml_age, 12) = 0
    THEN TO_CHAR (ROUND (anml_age / 12, 0) || ' Year(s) '
    ELSE TO_CHAR ( ROUND (anml_age / 12, 0)
    || ' Year(s) '
    || MOD (anml_age, 12)
    || ' Month(s)'
    END age_string
    from
    (SELECT a.*,
    CASE WHEN status IN ( 1)
    THEN FLOOR(MONTHS_BETWEEN(TRUNC(SYSDATE),dob))
    WHEN death_date IS NOT NULL AND status IN (2)
    THEN FLOOR(MONTHS_BETWEEN(death_date,dob))
    END anml_age,
    CASE WHEN status IN (1)
    THEN FLOOR(TRUNC(SYSDATE)-TRUNC(dob))
    WHEN death_date IS NOT NULL AND status IN (2)
    THEN FLOOR(TRUNC(death_date) - TRUNC(dob))
    END daysdiff
    from (
    SELECTanml.id, status,
    TO_DATE ( DECODE (b_date,
    NULL, 1,
    b_date
    || '-'
    || DECODE (b_month,
    NULL, 1,
    b_month
    || '-'
    || b_year,
    'dd-mm-yyyy'
    ) DOB,
    death_date
    FROM anml
    WHERE b_year IS NOT NULL
    ) a) top

  • How to convert the numeric to date format

    HI ,
         We have created the date KF and selected the data type as DEC-numeric or counter and add in the cube.
          the data for this fields in the cube are in numerics like  734.504, but when we execute the report it is converted in to date format dd.mm.yyyy.
                    My issue how this conversion is working in the backend while executing the report.
    Regards.
    venkata

    Conversion is happening because of the type you had selected for the KF while creating it.
    Check the type of the Key figure?
    While creating the KF you might have selected the Type as Date and Data type -DEC : Counter or amount field with comma and sign.
    that's the reason why you are getting the output values displayed in dd.mm.yyyy format.
    For amount field - create a KF with type "AMOUNT" and unit -0currency or specify the currency of that region.
    regards
    KP

  • How to get an international English date format if I'm in a country where the date format is something else?

    I'm physically in Malaysia and my iPad sets Malay as my default time format setting. How to get rid of the whole thing of using Malay as my date format and use English as default for everything including date and time ? Under setting> general > international, I have to choose something and English is not an option.

    You need to choose an English-speaking country - I have Settings > General > International > Region Format set to United Kingdom (as I'm in the UK), so the first day of the week is monday and times are of the format 01:23 etc (there also options for US, Canada, Australia etc)

  • How can i set user's date format?

    problem:
    I have two users daniel and william.
    daniel login the EBS and the date format is :yyyy/mm/dd
    william login the EBS and the date format is : DD-MON-RRRR
    How can i set date format for everyone?
    Thanks.
    Daniel.
    2006.11.16

    Check the system profile ICX: Date Format Mask. Is it set at the application level? Does each user have different date format?
    How do you access the application? Through ICXINDEX page or through dev60cgi/f60cgi?
    Please note that changing the above profile option will not affect users logging through dev60cgi/f60cgi, in case you need to change it for the users who are accessing the application this way you can use the FORMS60_USER_DATE_FORMAT parameter in the url

  • How can I permanently change the date format from the American format to the UK's without having to constantly change it manually every time I start a new spreadsheet?

    This is my first mac so I'm still getting my bearings with it. I've only used Windows programmes before. I can't understand why it's so hard to change the date format of the cells in Numbers to keep it showing the UK format. The system preferences of the mac show that it's in the correct region and has the correct date but this doesn't seem to transfer into the Numbers program. I was very impressed with the mac until I discovered this. If anyone knows how I can get the date to stay in the correct format without having to go through the process of altering it in the cell inspector everytime then I would be very grateful.

    Numbers & most apps, especially those from Apple, use the date format you have set in System Preferences > Language & Text > Region. You can then choose UK from the Region drop-down list. Mine says Custom because I've defined things further as in the second screenshot.

  • DateFormatContext - how to change default locale and date formatting?

    Hi,
    I need change default DateFormat e.g. from SHORT to MEDIUM, but I want to change default format for all pages, because I use for all bc4j:table automatic generation oc columns. Does anybody how to do it?
    I tried this:
    public void requestStarted(BajaContext context)
    Locale locale = new Locale("cs", "", "");
    MutableLocaleContext mContext = new MutableLocaleContext(locale);
    MutableDateFormatContext dfc = new MutableDateFormatContext(mContext.getDateFormatContext());
    But "dfc" doesn't have any set methods, where I could assign my formatter to the context:
    SimpleDateFormat DtFrmt = new SimpleDateFormat();
    // this I want to get to dfc
    dfc <== DtFrmt.getDateInstance(DtFrmt.MEDIUM, locale);
    Vl.

    I don't think this is possible. The dateField has a default validator on it which determines the date format, changing the dateFormatContext won't change the validator.

  • How to convert a String to Date format?

    the user enter a date in string format and the date is save in the database.
    The problem i am facing is i want to change from String to Date format.
    Here is my codes:
            public boolean insertData() throws Exception {
            boolean validFlag = false;
            DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            Date d = df.parse("05/18/05");
            String MY_DATE_FORMAT = "yyyy-MM-dd";
            String jobAdvertisementDate = new SimpleDateFormat(MY_DATE_FORMAT).format(d);
            String sql = "INSERT INTO companyjob (CompanyID,JobID, JobAdvertisementDate ) " +
                    " VALUES ('" + companyID + "','" + jobID + "', '" + jobAdvertisementDate + "')";
            System.out.println(sql);
            validFlag = executeSQL(sql);
            return validFlag;
        }The date is save under jobAdvertisementDate.
    My netbeans shows an error. There's a red line under DateFormat and parse inside my codes.
    PLease help me. Reply asap!!

    BebeGirl wrote:
    My netbeans shows an error. There's a red line under DateFormat and parse inside my codes.
    Red Line? Sounds ominous. I wonder what it means.
    So...what does the error say?

  • How can change numeric value to date format? example value 1070131(CYYMMDD)

    in the datatable can i change numeric value to date format . in database date value is like 1070131 (CYYMMDD). I want to see 31/01/07(DD/MM/YY) or 31 Jan 07 . Is it possible?
    Thanks,

    Did you solve your problem?

  • How to insert a record with date format field

    I tried to execute the query of the below but it showed error and hence i did research and found out i can add a date syntax in front to format it properly.
    INSERT INTO EMP (EmpNo, EmpName, Sex, DateOfBirth, Salary, DeptNo)
    VALUES ('E001', 'Alex', 'M', '2006-11-08', '1500', 'D001');
    When i executed the following query under SQL plus environment, it hang and gave no response. May i know how to solve this problem? Thank you
    INSERT INTO EMP (EmpNo, EmpName, Sex, DateOfBirth, Salary, DeptNo)
    VALUES ('E001', 'Alex', 'M', DATE '2006-11-08', '1500', 'D001');

    Normally when we execute a query, it will show the result or response whether it is fail or success or what the error message is. But my situation is that it showed nothing and no response, and cannot execute new query, i cant do anything under that environment and i can only off it by using end task.

  • ABAP Report WRITE, how to ouptut long lines without additional formatting?

    I am developing a program, which dumps objects as XML and I need to create one big XML file at the end. I would like to start it as a background job and get this XML as spooled output at the end. The problem is that the XMLs come from CALL TRANSFORMATION as one big string without any CR LF and in the report spooled output there are additional "formatting" like header, pages etc.:
    #COL0N#COL0H07.12.09 Programm EHFND_GENERATE_BO_DOCU                                       1
    #<bopf_bo><item><KEY>gB4L/AeoHd6tl1YoR5AdIg==</KEY><PARENT_KEY/><ROOT_KEY>gB4L/A
    #<bopf_bo><item><KEY>gB4L/AeoHd6tl2lLeQUKOQ==</KEY><PARENT_KEY/><ROOT_KEY>gB4L/A
    #<bopf_bo><item><KEY>gB4L/AeoHd6tmEQlByTUEg==</KEY><PARENT_KEY/><ROOT_KEY>gB4L/A
    #<bopf_bo><item><KEY>gB4L/AeoHd6xjRciawUXeQ==</KEY><PARENT_KEY/><ROOT_KEY>gB4L/A
    #<bopf_bo><item><KEY>gB4L/AeoHe6t31MGbgZYFg==</KEY><PARENT_KEY/><ROOT_KEY>gB4L/A
    P
    |#COL0N#COL0H07.12.09 Programm EHFND_GENERATE_BO_DOCU                                       2
    |#######################################################################################
    |#<bopf_bo><item><KEY>gCFaXDIYHe60jgYnuB9agQ==</KEY><PARENT_KEY/><ROOT_KEY>gCFaXD
    Is it possble to make the WRITE statement automatically insert CR LF so I do not loose the XML data and also do not output
    any additional symbols? My purpose is to get clean XML data at the end, which can be e.g. directly loaded into explorer.
    I already have a solution which fills a DB table with all XMLs and finaly I create the file with cl_gui_frontend_services=>gui_download but I would like to have a simplier solution using only the abap report output.
    Edited by: Rob Burbank on Dec 8, 2009 10:56 AM

    Better option would be writing this XML string to File on the application server using OPEN DATASET ... TRANSFER .... CLOSE DATASET. You can give the provision in the same program to download this application server file to Presentation.
    Regards,
    Naimesh Patel

  • How to Change CrystalRepXI Enter Values Date Format yyyy-mm-dd 2 mm-dd-yyyy

    I am using Crystal Report XI for Report Development.
    I  am accepting date parameter field in report. When I run the report a dialog box pops up for accepting the Input Date.
    and the format that it accepts is 'yyyy-mm-dd' can I change this to 'mm-dd-yyyy'.
    Please suggest some solution, thank you in advance.
    -Sachin Doshi

    Ananth,
    I require this because its a client requirement, My clients wants to have input format in the same way as he wants it to see in the report.
    I have seen the Dates javascript files and I am surprised to see that the format is hardcoded. I think this is something non-standard. Crystal is allowing the user to format the date on the report then why is it resitricting while accepting.This is something very basic.
    Is there any quick resolution to this apart from converting the Date field to String.
    Please Help.

  • How to print long raw text data in report output in single line?

    Hi All,
    I have a requirement where I need to print raw comma separated text data in the report output which end user will open in excel and can sort as required. I can not directly generate excel output.
    Now there is huge set of data and each row from the report query should be get printed on single line, It should not get printed on the next line.
    I tried to extending the report with 240 characters but still there are some text data which is getting printed on the next line.
    Please share your view if someone has any solution on this issue.
    Thanks in Advance.
    Arun

    Make the report even wider. By default a report layout can be 10 pages wide. If you need more, change the "Max. Horizontal Body Pages" property, and extend your layout too.
    IMHO, I wouldn't even use Reports to create a csv file. Utl_file or an sqlplus script that spools to a file are better options I think.

  • HOW TO DEBUG DB COLLECTOR - DATE FORMAT PROBLEM

    Hi All,
    i created a oracle collector. i have a query like below;
    select
    MY_DATE,
    TO_CHAR('MY_DATE','YYYY/MM/DD HH24:MI:SS','nls_date_language=AMERICAN')
    MDATE
    WHERE
    MY_DATE >= TO_DATE('%s','YYYY/MM/DD
    HH24:MI:SS','nls_date_language=AMERICAN') and rownum <= %d
    ORDER BY
    MY_DATE
    and i am returning 'return input.RXMap.col_MDATE;'
    When i run the collector it is giving to me ORA-01840 input value not
    long enough for date format so i want to debug and see the value of %s.
    When run the collector debug mod always saying to me NODATA. Anybody
    know how can debug and how can see %s value ??
    ibasaran
    ibasaran's Profile: https://forums.netiq.com/member.php?userid=2826
    View this thread: https://forums.netiq.com/showthread.php?t=46068

    ibasaran;221632 Wrote:
    > Hi All,
    >
    > i created a oracle collector. i have a query like below;
    >
    > select
    > MY_DATE,
    > TO_CHAR('MY_DATE','YYYY/MM/DD HH24:MI:SS','nls_date_language=AMERICAN')
    > MDATE
    >
    > WHERE
    > MY_DATE >= TO_DATE('%s','YYYY/MM/DD
    > HH24:MI:SS','nls_date_language=AMERICAN') and rownum <= %d
    >
    > ORDER BY
    > MY_DATE
    >
    > and i am returning 'return input.RXMap.col_MDATE;'
    >
    > When i run the collector it is giving to me ORA-01840 input value not
    > long enough for date format so i want to debug and see the value of %s.
    >
    > When run the collector debug mod always saying to me NODATA. Anybody
    > know how can debug and how can see %s value ??
    Make sure you start the event source after you start debugging.
    brandon.langley
    brandon.langley's Profile: https://forums.netiq.com/member.php?userid=350
    View this thread: https://forums.netiq.com/showthread.php?t=46068

  • How to convert the date format 'm/d/yyyy hh:mi:ss AM' to 'MM/DD/YYYY HH:M'

    How can i convert a the date format 'm/d/yyyy hh:mi:ss AM' to 'MM/DD/YYYY HH:MI:SS AM' in Oracle
    I have a query
    select UPPER(t.val_10) "TYPE", count(val_3) "Number of Transfers"
    from table1 t
    where t.is_active = 1
    and t.val_4 = 'INBOUND'
    and to_date(to_date(val_5,'MM/DD/YYYY HH:MI:SS AM'), 'DD/MM/YY') between to_date(to_date('01/08/2008 00:00:00','DD/MM/YYYY HH24:MI:SS'), 'DD/MM/YY') and add_months(to_date(to_date('01/08/2008 00:00:00','DD/MM/YYYY HH24:MI:SS'), 'DD/MM/YY'),1)
    group by UPPER(t.val_10)
    order by UPPER(t.val_10)
    I get the error [ORA-01861: literal does not match format string which i think is because
    val_5 has the values in the following format:
    8/29/2008 6:31:10 PM
    Does anyone have an answer?
    Thanks in advance
    Edited by: user2360027 on 26-Mar-2009 03:50                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    first off, you've got to_date(to_date(...)) - NEVER do this - you're forcing an implicit to_char which can cause all sorts of problems!
    What is the data type of your column val_5? If it's DATE then your query is simply:
    select UPPER(t.val_10) "TYPE",
           count(val_3) "Number of Transfers"
    from   table1 t
    where  t.is_active = 1
    and    t.val_4 = 'INBOUND'
    and    val_5 between to_date('01/08/2008','DD/MM/YYYY') and add_months(to_date('01/08/2008','DD/MM/YYYY') ,1)
    group by UPPER(t.val_10)
    order by UPPER(t.val_10)If it's a varchar2 (why, oh why, oh why, ...?!), then your query should be:
    select UPPER(t.val_10) "TYPE",
           count(val_3) "Number of Transfers"
    from   table1 t
    where  t.is_active = 1
    and    t.val_4 = 'INBOUND'
    and    to_date(val_5, 'mm/dd/yyyy hh:mi:ss AM') between to_date('01/08/2008','DD/MM/YYYY') and add_months(to_date('01/08/2008','DD/MM/YYYY') ,1)
    group by UPPER(t.val_10)
    order by UPPER(t.val_10)Remember that dates in DATE format are stored in an internal Oracle format - in order for you to tell Oracle that your string is a date, you need to use to_date. When you want to retrieve a date, you need to use to_char to put it into the format you want to see it in.
    Remember also that your nls_date_format defines the default format that you'll see a date, which is what is used in the implicit conversion that oracle does when you select a date:
    SQL> alter session set nls_date_format='dd/mm/yyyy hh24:mi:ss';
    Session altered.
    SQL> select sysdate from dual;
    SYSDATE
    26/03/2009 11:01:53
    1 row selected.
    SQL> alter session set nls_date_format='mm/dd/yy hh12:mi:ss AM';
    Session altered.
    SQL> select sysdate from dual;
    SYSDATE
    03/26/09 11:02:24 AM
    1 row selected.It doesn't make sense to convert something that's already in a DATE format into a DATE format - in order to do that, oracle has to first change the date into a string, and it does that by using the nls_date_format parameter setting - if you're working with dates-in-strings that are in a different format, then all sorts of problems arise, as you have found out!

Maybe you are looking for

  • How to upload data from excel to form using webutil

    Hi, In the sample provided by Oracle http://www.oracle.com/technology/products/forms/htdocs/webutil/howto_ole.html Note 247606.1 How to Copy Records From a Form Into Excel It shown the methods of how to copy data from form to excel but is there any s

  • Any way to set color for value in chart and still filter out values (but retain colors)?

    Is there any way that I can hard code a color into a chart and still filter out values? I have 5 divisions, each with a specific color.  I have put them into a stacked column chart and it looks fine.  My issue arises when I try to filter out some of

  • Customization of ESS 60.2 sp3

    hi to all how to customize the ESS iview i want to delete some fields and some into IVIews iam new to this area (JDI) i need the informatiom from scratch could pls explain me how to import into NWDS and how we customize the iviews

  • Help with date format in Procedure...

    Hi, I am very new to orcale development.... as my requirement have asked me i have written a procedure Procedure create or replace procedure MEXICO_NAFTA_CERTIFICATE_EXT ( f_org_id NUMBER, f_customer_nbr_base NUMBER, f_customer_nbr_sufx number, f_yea

  • After multi-mailbox search deleted the results are not cleared out of discovery mailbox?

    So my legal team has finally given me the OK to remove the results of a multi-mailbox search that the results of were sent to a discovery mailbox.   I've deleted the search, OK'd the warning indicating that the results of the search would be deleted