Help needed in date formating

Hi guys merry Christmas in advance .i was trying to write a code to compare given string with current date .
So i have written a piece of code to set hour minute second millisecond of current date to 0.
It worked fine for minute second millisecond but hour always shows 12.
Here is the code.
Please help
import java.util.*;
public class SampleDate
public static void main(String[] args)
java.util.Date date = new java.util.Date();
//convert current date to cal format and set hour min sec mill to 0
java.util.Calendar cal1=java.util.Calendar.getInstance();
cal1.setTime(date);
cal1.set(java.util.Calendar.HOUR,0);
cal1.set(java.util.Calendar.MINUTE, 0);
cal1.set(java.util.Calendar.SECOND, 0);
cal1.set(java.util.Calendar.MILLISECOND, 0);
//convert from cal to date format
date=cal1.getTime();
System.out.println("Current Date in Date Object: " + date);
}Output:
C:\TIMECOMPARE>java SampleDate
Current Date in Date Object: Thu Dec 24 12:00:00 IST 2009Expected output is :Current Date in Date Object: Thu Dec 24 00:00:00 IST 2009

The HOUR field of the Calendar class represents a 12 hour clock format where 0 indicates 12 noon. Instead use the HOUR_OF_DAY in the code as shown below:
cal1.set(java.util.Calendar.HOUR_OF_DAY,0);

Similar Messages

  • Need help in converting date format

    Hi,
    Need help in converting date format from 'DD-MON-YYYY' to 'YYYY-MM-DD' in an .rtf template as I believe xml publisher supports the date format as 'YYYY-MM-DD' only.
    Thanks,
    Raj.

    I got the same problem, anyone know how to solve this problem? I allready found some date functions on http://blogs.oracle.com/xmlpublisher/2008/09/date_functions.html . I also tried <?xdoxslt:month_name(xdoxslt:get_month(xdofx:substr(NEED_BY_DATE, 4,3)), $_XDOLOCALE), 0, 'nl-NL')?>, but then it returns a namespace error (Caused by: oracle.xdo.parser.v2.XPathException: Namespace prefix 'xdofx' used but not declared.). Anyone know how to fix this?
    Edited by: user11165753 on 7-dec-2009 23:50

  • HELP needed on Date

    Hi there everyone, pls help me . i have a question as above
    "Code a Java class called Calendar which has a static variable of type Date(initialised to 1st January 2004), a static void method called tock(int days) to advance the variable by the specified number of days, and a static Date method called getDate() to return the current date.".
    What i was thinking to write is.
    public class Calendar
    Date myDate = new Date();
    myDate = java.sql.Date.valueOf("2004-01-01"); //but my fren said i could use the toString() instead
    public static void tock(int days)
         {  int i = 1;
    while i < days;
    Date = Date + 1; // i am not sure what i am doing ...i am just a beginner .pls help
    public static Date getDate()
    { return Date;
    Are my answers correct ..? how do i advance the variable (date) by the number of specified days ? the asnwer need to print out, say 4 days , u need to print 01 Jan , 02Jan , 03 Jan , 04 Jan...
    anyone please help ..

    Since your assignment is to code a class named Calendar, I doubt that you can use the java.util.Calendar class,
    which has a useful add() method in it.
    So here is another solution:
    public class Calendar
        static Date myDate = java.sql.Date.valueOf("2004-01-01");
        public static void tock(int days)
            long t = myDate.getTime(); // returns the number of milliseconds since 1970-01-01 00:00:00 GMT
            t = t + (days * 24 * 60 * 60 * 1000); // adds the appropriate number of days in milliseonds
            myDate.setTime(t);
        public static Date getDate()
            return myDate;

  • Need help with converting date format to decimal in SSRS expression.

    Hi all,
    I have a decimal data type column with a record in the following format 20150219 --> yyyyMMdd. And I am trying to convert the return value from SSRS date/time parameter to a decimal value.
    The TMDTOP column is the decimal data type with date records in yyyyMMdd format.
    My return parameter is the following:
    =IIf(IsNothing(Parameters!SystemDate.Value),Fields!TMDTSY.Value,CDec(Format(Parameters!SystemDate.Value,"yyyyMMdd"))) 
    When I try to run the report I get the following error:
    Failed to evaluate the FilterValue of the DataSet ‘DataSet1’. (rsFilterEvaluationError)
    I appreciate if anyone can help me on solving this problem.
    Thanks in advance.

    why casting date to decimal here? Can you explain?
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Help needed in data type casting

    I have a java program which will receive data and its type in the String format. During program execution, the data in the String data has to be converted into the respective data type and assigned to a variable of that data type so that it could be used in the program. Programmer may not know the type of data that the value has to be converted into.
    I really got struck up with this. This is a RMI application and one process node is sending the data to another node in the String format and the type of data it should get converted into so that it can be converted into the respective type and used for computation.
    Can you understand what I am asking for ....if you can pls help and it is highly appreciated

    I dont know whether i ahve expressed it correctly
    look at this code
    dataPacket sendtoNode = send.senDatatoNode(inputReq);
    String recnodnum = sendtoNode.nodeNum;
    String recvarnum = sendtoNode.varNum;
    String recvartype = sendtoNode.dataType;
    String recvalvalue     = sendtoNode.dataVal;
    int num;     int type;
    double result;
    // here in this case the result variable type is double
    if (recvartype.equals("int")){
              type = 1;
         result = Integer.parseInt(recvalvalue); will pose problem
         else
         if (recvartype.equals("double")){
              type = 2;
              result = Double.parseDouble(recvalvalue);
         else
         if(recvartype.equals("float")){
              type =3;
              result = Float.parseFloat(recvalvalue); will pose problem
         else
         if(recvartype.equals("Boolean")){
              if ((recvalvalue.equals("true")) || (recvalvalue.equals("TRUE")))
              type = 4;
              result = Boolean.parseBoolean(recvalvalue); will pose problem
         else
         if(recvartype.equals("char")){
              type = 5;
              result = (char)recvalvalue; will pose problem
    else
    if(recvartype.equals("String")){
         type = 6;
              result = recvalvalue; will pose problem
         else
         if(recvartype.equals("byte")){
              type = 7;
              result = Byte.parseByte(recvalvalue); will pose problem
         else
         if(recvartype.equals("long")){
              type = 8;
              result = Long.parseLong(recvalvalue); will pose problem
         else
         if(recvartype.equals("short")){
              type = 9;
              result = Short.parseShort(recvalvalue); will pose problem
         //forvarval varvalue = new forvarval();
         //varvalue.forvarval(recvartype, recvalvalue);
    // this has to be done after sorting the problem of type casting string result = recvalvalue;
    //result = value; //<this will surely give me a problem as i m assigning string to double>??
    send.host(result);
    System.out.println("result received and the result is " +recvalvalue );
    now i need to assign the converted string in to a variable and use in the compuation ..thts where the challenge n not in teh conversion process...

  • Urgent help needed: registry.dat is missing when i run my form in web base

    Hi gurus,
    i configured my forms and report server in windows 2003 and i received the following error msg when tryin to access my web base forms 6I.
    FRM-92129: Registry file http://domain.com/form60java/oracle/forms/registry/Registry.dat is missing.
    Details...
    Java Exception:
    oracle.forms.engine.RunformException: FRM-92120: Registry file http://domain.com/form60java/oracle/forms/registry/Registry.dat is missing.
    at oracle.forms.engine.Runform.initRegistry(Unknow Source)
    at oracle.forms.engine.Runform.startRegistry(Unknow Source)
    at oracle.forms.engine.Main.createRunform(Unknow Source)
    at oracle.forms.engine.Main.start(Unknow Source)
    at sun.applet.JinitAppletPanel.run(Compiled code)
    at java.lang.Tread.run(Thread.java:466)
    what can be goes wrong with my steps to receive the above error?? i tried in windows XP and Vista, and i getting the same error message as above.
    Your urgent help and advise is needed plssssssss.......
    Many thanks in advance.

    The URL doesn't seem correct: http://domain.com/form60java/oracle/forms/registry/Registry.dat
    I'm expecting a slash (/) between forms60 and java. Have a look in the formsweb.cfg if any paths are misconfigured.
    Also, try if the URL with the slash:
    http://domain.com/form60/java/oracle/forms/registry/Registry.dat
    does work when you just paste it in a browser. It should download the Registry.dat file

  • Mapping conversion help needed for date

    Hi Experts,
    I need help in message mapping convesion for date field
    The source date field can have value '2010-06-04T02:09:59.610-07:00' or 2010-06-04T02:09:60.610-07:00
    I have to change it to '2010-06-04T02:09:59.000-07:00'. ie, if the seconds are 59.XXX, or 60.XXX, then change to 59.000.
    Please let me know the best way to do this
    Thanks
    Mike

    Again, to make it more clear
    The source date field can have any date value such as
      2010-06-04T02:09:59.610-07:00 -
    This needs to be changed to 2010-06-04T02:09:59.000-07:00
      2010-06-04T02:09:60.610-07:00 -- This needs to be changed to 2010-06-04T02:09:59.000-07:00
    2010-06-04T02:09:60.000-07:00 -- This needs to be changed to 2010-06-04T02:09:59.000-07:00
    2010-06-04T02:09:59.000-07:00  - This need not be changed
    2010-06-04T02:09:58.610-07:00 -- This need not be changed
    2010-06-04T02:09:57.610-07:00  etc etc - These need not be changed.
    The only change using date function is for the first two dates, in which 59.XXX and 60.XXX need to be replaced with  59.000
    Using the above date function, all the seconds 59.XXX, 58.XXX, 60.XXX, etc etc,,, are converted to 59.000, 58.000 and 60.000
    I dont need this as per the requirement. So looks like the UDF needs to be altered a little to accomodate my requirement.
    Please help me.
    Thanks
    Mike

  • Help needed with data security

    I need to return my Thinkpad for service but I am concerned with security. For instance, my facebook account as well as other accounts log on automatically because the passwords are automatically remembered. How do I keep my confidential information safe while the laptop is in the technicians hands?
    BTW, one of the problems that it has is that I cannot backup successfully with the lenovo application... I managed to get a backup completed with the windows backup program, but I'm not sure of it's integrity.
    Please help me with this, Thanks!

    Hi,
    If I understand you correctly, you suspect software problems.
    The first thing the techs will do (probably) is re-image your HDD.  I hope you have you important data backed up somewhere - especially if you don't trust the Windows backup.
    For that matter, if you do have software issues, restoring a full backup will also restore the problem.
    You've probably already considered this, but just in case...
    Z.
    The large print: please read the Community Participation Rules before posting. Include as much information as possible: model, machine type, operating system, and a descriptive subject line. Do not include personal information: serial number, telephone number, email address, etc.  The fine print: I do not work for, nor do I speak for Lenovo. Unsolicited private messages will be ignored. ... GeezBlog
    English Community   Deutsche Community   Comunidad en Español   Русскоязычное Сообщество

  • Help Needed in Date Logic

    Hi I am working in sqlserver 2008 R2 and below is my sample research query
    i am trying to get previous 6 months data.
    WITH CutomMonths
    AS (
    SELECT UPPER(convert(VARCHAR(3), datename(month, DATEADD(MM, DATEDIFF(MM, 0, GETDATE()) - N, 0)))) Month
    ,DATEADD(MM, DATEDIFF(MM, 0, GETDATE()) - N, 0) startdate
    ,DATEADD(MM, DATEDIFF(MM, 0, GETDATE()) - N + 1, 0) enddate
    FROM (
    VALUES (1)
    ,(2)
    ,(3)
    ,(4)
    ,(5)
    ,(6)
    ) x(N)
    WHERE N <= 6
    SELECT month
    ,SUM(isnull(perks.amount,0)) AS PerkAmount
    FROM CutomMonths
    LEFT JOIN (
    select 10.00 as amount,'2014-04-03' as StartDate,'2015-04-03' as EndDate union all
    select 10.00 as amount,'2014-04-03' as StartDate,'2015-04-03' as EndDate
    ) perks ON
    CutomMonths.startdate >= perks.StartDate
    AND CutomMonths.startdate < perks.EndDate
    GROUP BY CutomMonths.Month
    ,CutomMonths.startdate
    ORDER BY CutomMonths.startdate ASC
    current output what i am getting:
    Expected Output:
    I found why the April month i din't get the $20 because the startdate of my perks CTE '2014-04-03'. If it is '2014-04-01' then i will get the expected output.
    But i should not change the the date on perks. How to neglect this date issue and consider the month instead to get the expected output. please help me on this as i am struggling on my logic 
    loving dotnet

    I'm just going to focus on the JOIN criteria in this reply since my answer above and your 2nd response are essentially the same except for the JOIN.
    What your are describing and what you are doing in code is conflicting. 
    You are saying this:
    "I just need to check whether the perks start date falls in between month start date and month end date"
    ..., which translated directly to code would be this:
     ON perks.StartDate >= CustomMonths.StartDate
    AND perks.StartDate <= CustomMonths.EndDate
    What I believe you are getting after is this:
    "I just need to check whether the dates within the perks start and end date range fall in between month start date and month end date"
    ..., which translated directly to code would be this, which is also my answer proposed above:
    ON CustomMonths.StartDate >= DATEADD(DAY, -(DAY(perks.StartDate) - 1), perks.StartDate)
    AND CustomMonths.StartDate <= perks.EndDate
    However, if you really want to use the code solution you proposed, then you would actually be saying this:
    "I just need to check whether the dates within the perks start and end date range fall in between month start date and month end date, but if perk end date happens to be the first day of the month, then ignore it and use the previous day."
    ..., in which case then your code, as follows, would be the solution:
     ON CutomMonths.startdate >= DATEADD(mm, DATEDIFF(mm, 0, perks.StartDate), 0)AND CutomMonths.startdate < DATE
    ADD(mm, DATEDIFF(mm, 0, perks.EndDate), 0)
    NOTE: The alternate JOIN I had commented out in my proposed answer above will do the exact same thing as your latest proposed solution
     ON CustomMonths.StartDate >= DATEADD(DAY, -(DAY(perks.StartDate) - 1), perks.StartDate)
    AND CustomMonths.StartDate < perks.EndDate
    BTW, I see how you are getting to the first day of the month by subtracting all the months from the given date to 01/01/1901, and then turning around and adding them all back to 01/01/1901.  While that is one way to get to the first day of the month, it
    seems excessive from a calculation stand point, although I haven't performed any performance tests to know for certain.
    SELECT DATEADD(mm, DATEDIFF(mm, 0, '2014-04-03'), 0)
    I prefer simply subtracting one less than the current day number from the given date to get to the same first day of the month value.
    SELECT DATEADD(DAY, -(DAY('2014-04-03') - 1), '2014-04-03')

  • Help needed with File Formats (Save As...)

    Somewhere upgrading versions of Photoshop (Mac), some old File Formats have remained. The result is that I cannot properly select a File Format to Save As... except the native PSD format. Others have to be selected by selecting a format below the one on the list, meaning that I cannot select TIFF because there are no formats below this one. (Accepted formats http://help.adobe.com/en_US/photoshop/cs/using/WSfd1234e1c4b69f30ea53e41001031ab64-7758a.h tml#WSfd1234e1c4b69f30ea53e41001031ab64-7754a)
    I've looked in the Plugins folder and there are no strange file formats there. I checked Library>Application Support>Adobe>Plug-Ins but nothing there. I've tried searching the entire hard drive for Compuserve GIF (one of the offending file formats) but nothing matches.
    I give up trying to figure out where some of the problem plugins are located. As you can see from the image below, selecting Multi-Picture Format actually will save it as a jpg. From reading Adobe's formats, I think CompuServe GIF is causing part of the problem. I don't know what other one.
    Or it may be that I just need to reset something so all formats are properly recognized. Can anyone help?

    Curt,
    That is great information. Unfortunately I've already checked the preferences and do not have an additional plugin folder specified.
    Suppossedly, according to the information from Adobe, the only place plugins should be loaded is in the Photoshop > Plug-Ins folder, or possibly Library>Application Support>Adobe>Plug-Ins (according to the link you provided). There is nothing there.
    When I look at Photoshop > About Plug-ins I see that, for example, there are two (2) versions of CompuServe GIF format. Obviously one is old from a previous install/update, but I cannot find it anywhere. If I could find it, I could remove it. I suspect that is one of the conflicts causing my problem, but I see no way in Preferences to remove a plug-in. The link you gave says to move it outside the folder, but it presupposes you can even find the offending plug-in, which I cannot.
    Monty

  • Help Needed with Data-modeling to build an application on

    Hi would anyone be able to help me in creating a data model  cause im really stuck with this one .Basically if been asked to create a survey application in oracle apex that use to excel based . So the info i was given was in a form of  excel sheet which looks like this
    NAME
    E-MAIL
    TSSA
    ORACLE
    HP
    IBM
    MS
    SAP
    INTERGRAPH
    CISCO
    Relationship
    Contracting
    Performance
    Architecture
    Supplier Feedback
    comments
    Jxxxxxx yyyyyyf
    [email protected]
    Yes
    Yes
    Yes
    Yes
    x
    requested to be added
    nnnitha iiiiiah
    [email protected]
    Yes
    Yes
    Yes
    x
    x
    Knnnn kkkikot
    [email protected]
    Yes
    x
    x
    is not payed
    Gggrt Louuuue
    [email protected]
    Yes
    Yes
    Yes
    Yes
    Yes
    Yes
    Yes
    Yes
    x
    x
    x
    x
    jeiiiha ad
    [email protected]
    Yes
    x
    to meet with
    John Rat
    [email protected]
    Yes
    x
    x
    So where it says yes thous are the vendors that people associated with them have to asses and where there's an X thous are the topics that the vendors have to be rated on . So if for example the first guy on the list Jxxxxxx yyyyyyf will asses TSSA , ORACLE, HP , IBM , MS , SAP  on the topic of Architecture and if you look at the second user nnnitha iiiiiah he would rate TSSA , ORACLE , INTERGRAPH on the topics of Relationship and performance  . Any idea how i could data model this to get my table structures right .so that features like completion status could be displayed to the user through APEX which can only be done by a correct data-model i have tried normalization but  i did go anywhere becauce there are so many variations any idea on how you would go about data modeling this would be greatly appreciated thank you    

    Not really an APEX specific question..  Maybe you should try posting this in the data modeler forum : SQL Developer Data Modeler
    Thank you,
    Tony Miller
    LuvMuffin Software

  • Help needed in getting formatted output ?

    Hi members,
    I am a newbie in Java programming. I know C, C++ upto a good level. I was trying to print a pattern like:
    1
    12
    123
    1234
    12345
    But wasn't able to get the output in desired format. I just wanna know how can i get the above mentioned output. The code i written is shown below alongwith the output:
    /* This program is used to print the Pattern of 1,12..... */
    class pattern
         public static void main(String args[])
              int i=1,j=1;
              while(i<=5)
                   j=1;
                   while(j<=i)
                        System.out.println("\t "+ j);
                        j++;
                   i++;
                   System.out.println("\n");
    output:
    F:\Jprograms>java pattern
    1
    1
    2
    1
    2
    3
    1
    2
    3
    4
    1
    2
    3
    4
    5
    F:\Jprograms>
    Any help will be appreciated.
    With regards
    Real Napster

    It's the statement you're using to print to the console:
    println() means print, then go to next line.
    print() doesn't go to the next line.
    So:
    System.out.println("1");
    System.out.println("2");
    Gives
    1
    2
    But System.out.print("1");
    System.out.print("2");
    Gives
    12

  • Help needed in soaprequest formatting in Objective C.

    Hello, Good evening.
    Please can someone help me in fortmatting my code, I have been trying for 2 days to pass the correct parameters to a web service without success. Due to the issues with wsmakestubs i was unable to use the inbuilt WS methods in ocjC, so i decided to roll my own Soap request..
    the problem im hitting now is with double quotes and the removal of them in the compile.
    Please find below my code, and i do hope someone out there will be able to assist.
    these two lines error on compile due to the double quotes on line one around the "(1.0)" and "(utf-8)"... my code needs to keep this in the row.
    line two same again double quotes are needed around the paths. but build they error.
    <<<Start of Code>>
    [soapRequest appendString:@"<?xml version="(1.0)" encoding="(utf-8)"?>"];
    [soapRequest appendString:@"<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"<xmlns:xsi="http://www.w3 .org/2001/XMLSchema-instancexmlns:xsd=http://www.w3.org/2001/XMLSchema>""];
    Thanks again.!
    Regards
    Iain Smith

    Usually the standard escape sequence is to use a backslash before the double quote. I have not tried that in Objective-C, but would be surprised if it does not work.

  • URGENT help needed:Address data missing after QA Refresh from PRD

    All,
    Address data for almost all user-ids are missing after QA Refresh from PRD.
    In QA, after importing the User-Master although its shows successful. The detailed log shows:
       Data inconsistency in USR21. Start RSADRCK2 (See Note 459763)
       Exit program AFTER_IMP_ADDRESS3 successfully executed
       SAP user has no address SAP*
       Error while deleting ADRVP for SAP*
       SAP user has no address SAPCPIC...
       ERROR: Type "F" user exit with SYS_ERROR:     SUSR_CLIENTCOPY_USERBUF_RESET
    We also do a Table export - import wherein the tables
    USR03
    USR07
    USR09
    USR20
    USR21
    USR30
    are included.
    The no. of entries exported and imported are same.
    Also FYI in the User-master Transport i can see the following Tables included in the object list
    USR01
    USR02
    USR04
    USR05
    USR06
    USR08
    USR14
    USR21S
    USR22
    USRACL
    USREXTID
    USREXTIDH
    Has anyone seen this before?
    Any body has any ideas?

    Hello Bidwan,
    I think it is an issue with company address. Just check if  company addresses are existing the source client ?After client copy company addreses of target client will only exist in source client. Then if you do impot of the transport containing USR* tables it will try to assign old company addresses to the users but probably they are not exisitng in target client any more.
    If this is the case then you need to create those company addresses again using SUCOMP and then once again import the transport for user master.
    Regards.
    Ruchit.

  • Sql query need for date format''Mon 23 Apr 16:45 pm'

    i need SQL query to print date like 'Mon 23 Apr 16:45 pm' format

    SQL> select to_char(sysdate,'Dy fmddfm Mon hh24:mi pm','nls_date_language=american') from dual
      2  /
    TO_CHAR(SYSDATE,'DY
    Fri 27 Apr 13:04 pm
    1 rij is geselecteerd.Regards,
    Rob.

Maybe you are looking for

  • How to setup Security during installation

    Hi Experts,    Please let me know how to achieve "Setting up security for service-level accounts (page 12 in SAP BPC 5.1 Master Install Guide)"... I have created 3 users in my windows server 2003:              1.Administrator (member of Administrator

  • How I can get Logic pro 7?

    I have used Logic since the day it was "born" till version 5.5 (on Pc). Now I bought Logic pro 9  (& Mac...) and succeeded to load songs from version 5.5 but when I loaded songs from former version, I think 4.0, I have got a note says that I need ver

  • Legend arrangement

    Hi All, I have a bar graph which has 300 width. I am using one measure column namely "Plan", I have used the Scale Marker option, Scale Market legend name is "AAAA BBBB CCCCC" which is in three words. Now the bar graph displaying two legends 1) Plan

  • Muvo 256 TX FM recording prob

    I can get it to start recording fine, but I can't get it to stop! I can leave the play/pause button pressed for as long as I want, but it won't stop recording. I can't exit out of recording mode either, I have to remove the player from the battery ho

  • Installation error message: TARGETDIR is undefined

      I built the distribution package and it installs software fine on XP and W7 based systems. But under one PC with Windows Vista I got the next error message (pic 1) instead of offering to choose the installation directories (pic 2). Do you have any