01.01.0000 date parse and format

Could somebody explain is wrong here?
SimpleDateFormat frm = new SimpleDateFormat("yyyyMMddHHmmss");  // formatter
frm.setTimeZone(TimeZone.getTimeZone("UTC"));   // UTC time zone
// --- No problem for the next code ---
String inDate = "19700101000000";  // 01.01.1970 input date
long stamp;
try {
    stamp = frm.parse(inDate).getTime();   // input date in long
} catch (ParseException ex) {
    System.out.println("Interruption");
    stamp = 0;
String outDate = frm.format(stamp);  // output date
System.out.println("inDate=>" + inDate + "_longDate=>" + stamp + "_outDate=>" + outDate);
// --- No idea why next code is working wrongly ---
inDate = "00000101000000";  // 01.01.0000 input date
try {
    stamp = frm.parse(inDate).getTime();   // input date in long
} catch (ParseException ex) {
    System.out.println("Interruption");
    stamp = 0;
outDate = frm.format(stamp);  // output date
System.out.println("inDate=>" + inDate + "_longDate=>" + stamp + "_outDate=>" + outDate);I try to parse and format the time stamp 01.01.0000 00:00:00. On the finish I have 01.01.0001 instead of the correct 01.01.0000
inDate=>19700101000000_longDate=>0_outDate=>19700101000000
inDate=>00000101000000_longDate=>-62167392000000_outDate=>00010101000000

You are calling format with a long parameter. The only format that matches that signature that I can see would be Format.format(Object) assuming autoboxing is changing the long to a Long.
Format.format(Object) eventually calls DateFormat.format(Object, StringBuffer, FieldPosition). I have never used this method so I am not sure what it does.
Was your intention to actually call this method?
See the following example:
System.out.println("Test 1: " + frm.format(new Long(0l), new StringBuffer(), new FieldPosition(0)));  
System.out.println("Test 2: " + frm.format(new Long(-62167392000000l), new StringBuffer(), new FieldPosition(0)));  
Test 1: 19700101000000
Test 2: 00010101000000Edited by: jbish on Apr 26, 2013 12:43 PM
Edited by: jbish on Apr 26, 2013 1:09 PM

Similar Messages

  • JSTL Date Parse and Format

    Dear Friends,
    I have been trying for the last few days to run the below code but unfortunately I am getting the same error message. I have wasted a lot of time.
    I am using below jar files comes that with JSP(tm) Standard Tag Library 1.1 implementation downloaded from apache.org
    ( I have put the below jar files in Tomcat 5.5\webapps/projectname/WEB-INF\lib)
    1) jstl.jar
    2) standard.jar
    The JSP container I am using is Tomcat 5.5.9. The JDK version using is 6.0
    Please kindly help. Thanks in advance.
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
    <html>
    <head><title>JSTL Date</title></head><body>
    <fmt:parseDate value='10/25/2007 14:00' var='parsedDate' pattern='MM/dd/yyyy kk:mm' />
    Formatted Date :
    <fmt:setTimeZone value='America/New_York' />
    <fmt:formatDate value='${parsedDate}' type='both' timeStyle='full' />
    </body>
    </html>
    ===================================================
    output
    ===================================================
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: jsp.error.beans.property.conversion
         org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:885)
         org.apache.jsp.count_005fdown_005ftest_jsp._jspx_meth_fmt_formatDate_0(org.apache.jsp.count_005fdown_005ftest_jsp:132)
         org.apache.jsp.count_005fdown_005ftest_jsp._jspService(org.apache.jsp.count_005fdown_005ftest_jsp:73)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
    Apache Tomcat/5.5.9
    ===================================================================
    If I change the kk for the hour to hh as below
    <fmt:parseDate value="10/25/2007 14:00" var="${parsedDate}" pattern="MM/dd/yyyy hh:mm" />
    Formatted Date :
    <fmt:setTimeZone value="America/New_York" />
    <fmt:formatDate value="${parsedDate}" type="both" timeStyle="full" />
    I am getting the below error message
    ============================================================
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: javax.servlet.jsp.JspException: In <parseDate>, value attribute can not be parsed: "10/25/2007 14:00"
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:844)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
         org.apache.jsp.count_005fdown_005ftest_jsp._jspService(org.apache.jsp.count_005fdown_005ftest_jsp:83)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.text.ParseException: Unparseable date: "10/25/2007 14:00"
         java.text.DateFormat.parse(Unknown Source)
         org.apache.taglibs.standard.tag.common.fmt.ParseDateSupport.doEndTag(ParseDateSupport.java:178)
         org.apache.jsp.count_005fdown_005ftest_jsp._jspx_meth_fmt_parseDate_0(org.apache.jsp.count_005fdown_005ftest_jsp:102)
         org.apache.jsp.count_005fdown_005ftest_jsp._jspService(org.apache.jsp.count_005fdown_005ftest_jsp:64)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
    Apache Tomcat/5.5.9

    You are calling format with a long parameter. The only format that matches that signature that I can see would be Format.format(Object) assuming autoboxing is changing the long to a Long.
    Format.format(Object) eventually calls DateFormat.format(Object, StringBuffer, FieldPosition). I have never used this method so I am not sure what it does.
    Was your intention to actually call this method?
    See the following example:
    System.out.println("Test 1: " + frm.format(new Long(0l), new StringBuffer(), new FieldPosition(0)));  
    System.out.println("Test 2: " + frm.format(new Long(-62167392000000l), new StringBuffer(), new FieldPosition(0)));  
    Test 1: 19700101000000
    Test 2: 00010101000000Edited by: jbish on Apr 26, 2013 12:43 PM
    Edited by: jbish on Apr 26, 2013 1:09 PM

  • Line graph date sorting and formatting

    Hi Gurus
    We've recently upgraded to 11.1.1.7 and noticed that our Publisher line charts with date on the x-axis are no longer sorting correctly i.e. May comes before March. The reason for this is because in <11.1.1.7 we have a formatted date mask (to_char) in our data model but sorted by the underlying canonical date which worked. Now in 11.1.1.7 it is no longer sorting by the data model sort but by the formatted date string therefore numeric values of 30 April sorted after 1 May.
    We have tried a number of options to resolve:
    1. using the canonical date and sorting on that corrects the sort problem but the default formatting used in long YYYY-MM-DDT00:00:00-00:00 and not readable as our chart is showing daily totals. Changing to time-series chart can allow you to format the date but see problem 2 next...
    2. Time series = yes doesn't display the chart if we have a number of entities in our series i.e. multiple lines and the interactive viewer shows a red error icon. I think this may be due to the fact that our date range is not continuous ie we have a sparse data set.
    3. Workaround we used was a bar chart (our users preference is line charts) with time series = false but the date format is still long.
    Any advice / suggestions would be helpful.
    Thanks
    Nick.

    for #1: numbers does what is called a "stable" sort. Meaning that the previous sort order is preserved. i.e. do your sort in reverse order. Amount, then name, then date. Just did it with sample data and it was perfect. It keeps them in the original order, so if there is a match in name after you sort, you should see the amount still in the proper order.
    #2: What in your formula isnt working? I just made a formula that did math on the columns to the left, sorted and it worked. Sorted by static data columns and the formula column. I know it was broken originally, years ago, but it seems to be working correctly now, at least in my quick test. You might have an issue if you are using formulas that refer to data on other rows or tables.
    #3: yeah formatting can be a pain. But it is easier to do in the desktop program. No, you cannot get it for windows, sorry. If the formatting the only thing you need to do on the desktop side, then i dont see much tying you to it. I do 90% or more on the ipad and iphone now.
    Jason

  • Date Range and Format

    Post Author: cht104
    CA Forum: Formula
    I'm new to Crystal Reports so please bear with me.  I know this is easy and I'm just overlooking something obvious.  I've got my report formatted and working except for the getting the date range or prompt to work and the format of the date itself.  In my db, I"ve got a business_date field.  I've got that showing line by line in the report as yyyymmdd, but would like to be formatted as "Sept 11, 2007" if possible.  Also, for the date range, do I create a new formula or a new parameter field?  How exactly is that written out?  What other fields do I need to make this work?
    Thanks

    Post Author: cht104
    CA Forum: Formula
    {svc_at_dtl.svan} in &#91;"6036281297496447218", "6036281364474453041", "6036281475774461110", "6036282939574448316", "6036283115974448365", "6036283168796454200", "6036283395374462621", "6036283428674464130", "6036283753674445017", "6036283917774448418", "6036284153974449933", "6036284173996439566", "6036284257574445663", "6036284361474459493", "6036284371896470723", "6036284564874451909", "6036284758774459807", "6036284826974450872", "6036285282174468325", "6036285293874448033", "6036285529874453024", "6036285878174449855", "6036285999874448376", "6036286146296452491", "6036286186574458053", "6036286295596460760", "6036286335874446410", "6036286646674450703", "6036286674874445497", "6036286684874459826", "6036286879696436611", "6036286931974449860", "6036287191974445657", "6036287211774459063", "6036287254874446061", "6036287383874459108", "6036287395174475302", "6036287623696439776", "6036287911274449966", "6036287957774450009", "6036287972296473818", "6036289199196440994", "6036289336796478839", "6036289461796466359", "6036289792974471912", "6036289991196439695", "6275291111939468538", "6275291157455722999", "6275291342555724487", "6275291349939479559", "6275291437655724303", "6275291762455755275", "6275291867155724609", "6275291881655723946", "6275291886155724011", "6275292136155723957", "6275292195855724215", "6275292343855800229", "6275292363155724577", "6275292365155724637", "6275292431555731180", "6275292566755724381", "6275292632355723225", "6275292782455724172", "6275292851255723933", "6275292878655723921", "6275292953555723341", "6275293164155723919", "6275293169955723998", "6275293186455724649", "6275293318855723908", "6275293356655724478", "6275293373655724684", "6275293393739479064", "6275293553155724455", "6275293563655724004", "6275293586555778116", "6275293685955724201", "6275293757339475631", "6275293831955724141", "6275293834955730584", "6275293839562464447", "6275293884455723803", "6275293891639475878", "6275294142955724627", "6275294225939469203", "6275294244755724273", "6275294288755724162", "6275294326839466482", "6275294372355724667", "6275294446455724442", "6275294544655723239", "6275294595362458066", "6275294789855747474", "6275294965255727665", "6275295235155724432", "6275295284562503051", "6275295464555724584", "6275295543955724533", "6275295627755723584", "6275295787355723841", "6275295794955723386", "6275295812555723983", "6275295843555791857", "6275295862755722759", "6275295886755724259", "6275295914155723433", "6275295926255723304", "6275296134855724618", "6275296221455724401", "6275296317755723398", "6275296367355723312", "6275296369339471746", "6275296395339476301", "6275296663855724390", "6275296685255723246", "6275296714755724469", "6275296726455767720", "6275296746555724281", "6275296765355724086", "6275296772362502797", "6275296786862497240", "6275296997255724379", "6275297253355723475", "6275297266655724182", "6275297333955724555", "6275297497155723555", "6275297524455723179", "6275297573255724675", "6275297577455724220", "6275297741455812692", "6275297792755724410", "6275297869455724110", "6275297869455724110", "6275297899755723655", "6275297937155723570", "6275298123755730444", "6275298141555724499", "6275298269755791964", "6275298321455723972", "6275298361655724339", "6275298483355724658", "6275298658455722739", "6275298713155724108", "6275298747639512868", "6275298786555723464", "6275298854355724511", "6275298949755724320", "6275298993755724244", "6275299172655724547", "6275299224655724095", "6275299261439479425", "6275299271562505976", "6275299287155767711", "6275299417555724234", "6275299445555724363", "6275299463755727679", "6275299497755724052", "6275299561855724508", "6275299721255723338", "6275299743555724319", "6275299745855724293", "6275299755255769069", "6275299792555723668"&#93;anddate(tonumber({svc_at_dtl.business_date}&#91;1 to 4&#93;), tonumber({svc_at_dtl.business_date}&#91;5 to 6&#93;), tonumber({svc_at_dtl.business_date}&#91;7 to 8&#93;)) in {?date_range}
    I dont' know if my problem is with the "and", running 2 different things in here or just the date prompt.  Without the date prompt, I get my number information correctly

  • Best Data rate and format for Big Screen Playback

    I am a video producer supplying content for a tradeshow display consisting of 18 flat screens oriented vertically, 8 over 8. Very heavy duty Windows playback machine, with 3 graphics cards, 1 for each set of 6 monitors. The total pixel size is 3240x 1280 px. We have produced a number of full screen and smaller movies that the interactive programmer is trying to intergrate into a Flash program where some videos will play full screen, and others in smaller windows (those were produced in 1920x1080). All videos were mastered at the specified pixel count, square pixels, progressive, and output in Pro Res 422, 44.1K audio. Flash is being used to create the interface, and I am transcoding to .F4V at lower bit rates like 4, 6, and 9 Mbps. They are having trouble playing these movies back smoothly. We have done similar projects in the past with Director without issue. Of course they are blaming the video, I am offering to encode in any format at any data rate they suggest. Can anyone suggest a direction here?

    Are you trying to burn a standard DVD or are you trying to put a QuickTime .mov file on DVD media?
    A standard DVD doesn't worry about file size (only the duration).
    A "data" DVD is limited to the type of media used. A single layer DVD is about 3.7 GB's.
    In order to make a data DVD you need to keep the data rate low enough to not exceed the DVD media playback abilities. They can't handle the higher rates found in many of the preset options.
    You can avoid all of these headaches by telling the viewer to "copy" the .mov file from the DVD to their Desktop. Then nearly any of the presets option will work.
    H.264 is a great video codec and the "automatic" preset should work just fine. Use "multi-pass" for best quality (takes a very long time). Remove the check mark for "Audio" since your file has none. Leave it checked and you waste file size because a silent audio track would be added.

  • Jquery Date Picker Validation - format issue

    Hi ,
    I am using 2 text items with Jquery dateicker for start date and end date items.
    I have to now write a JS validation to ensure start date <= end date.
    The dateformat of my items are 'd-M-yy' (02-Mar-2010) .....
    When I try to use the Date.parse() function , it gives me an invalid date error....
    If I change the date format to mm/dd/yy (03/02/2010) then there is no problem, I can use Date.parse() and compare the two dates, I get no error . However I need the date format to be : 02-Mar-2010
    Below is a simple version of the JS function Iam using to compare dates and alert error
    function f_validate()
    var a = $v('P1_START_DATE');
    var b = $v('P1_END_DATE');
    var startDate = new Date();
    var endDate = new Date();
    startDate = Date.parse(a);
    endDate = Date.parse(b);
    // if I alert() startDate or endDate it says invalid date
    if (startDate>endDate){
    alert('error');
    else
    doSubmit();
    } Has anybody done a similar validation with Jquery datepickers in the format 'd-M-yy' ?
    Also how Can I use $.datepicker.parseDate function within my Javascript function so that I can convert the dates to the default format and then compare them....
    Appreciate any ideas/pointers
    Thanks,
    Dippy
    Edited by: Dippy on Mar 2, 2010 12:42 AM

    I've used the following without problems:
       var gasDay = $v('P0_GAS_DAY');
       var gasDayDate = new Date();
       gasDayDate = $.datepicker.parseDate('dd-M-yy', gasDay,
          monthNamesShort : ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC']
       );

  • HELP, date class and parsing input

    I have reviewed many posts in these forums and have found that detail gets the best results so I apologize in advance if this is detailed. I am taking a Java class and am not doing so hot. The last time I programmed was in 1998 and that was Ada, I very soon moved to Networking. I guess those that can't program become networkers, I don't know, but I am frustrated here.
    Any how I am trying to write a rather simple program, but it is the manipulation of the date I am having difficulty with. Here are the requirements:
    Overall Requirements
    Create a class named Date that stores date values and prints out the date in either a pure numeric format or a name and number format (see sample session for format details).
    Date.java class file
    ? Date objects should store the date in two int instance variables &#9472; day and month, and it should include the String instance variable, error, initialized with null.
    Implement a 1-parameter Date constructor that receives a dateStr string parameter and performs complete error checking on the given dateStr value. The Date constructor is the entity that?s responsible for date error checking. That way, if a Date object is instantiated and if there are no errors, then you?re guaranteed that the Date object holds a legitimate date value. If any kind of error occurs, change the value of the error instance variable to a non-null string value, using an appropriate concatenation of a string constant, input substring, and/or API exception message.
    Constructors use the same exception handling rules as methods: In a try block, include the parsing of the month and day substrings and other error-checking logic that will not work if parsing fails.
    ? Take into account the actual number of days in each month, but assume that there are always 28 days in February.
    ? To extract day and month numbers from the given date string, use String?s indexOf method to find the location of the slash character, and String?s substring method to extract month and day substrings from the input string.
    ? Include a method for printing the date with a numeric format. Use the zero-pad flag in a printf method call to get exactly two digits for each month and day.
    ? Include a method for printing the date with an alphabetic format.
    Include a getError method which returns the value of the error instance variable.
    DateDriver.java class file : In your driver class, include a loop that repeatedly:
    ? Asks the user to enter a date or ?q? to quit. ? If the entry is not ?q?, instantiate a Date object.
    ? If the error variable is null: o Print the date using numeric format.o Print the date using alphabetic format. Otherwise, print the value of the error variable.
    I want to figure this out on my own as much as possible but have until tomorrow night to do so..............I need to understand how I can use Strings indexOf to parse the dateStr so I can locate the /. I see I can use it to find the position of a specified character, but I am not sure of the syntax I need to use. But then once I find the / I need to use the String's substring method to extract month and day. I think I might be able to get that, if I can get the / figured out.
    The below is what I have in my Class and my Driver so far:
    *DateDriver.java (driver program)
    * Christine Miller-Lane
    *Overall Requirements
    *Create a class named Date that stores date values and prints out the date in either a pure numeric
    format or a name and number
    *format (see sample session for format details).
    *DateDriver.java class file
    *In your driver class,
    *????????? If the error variable is null:
    *     &#9702;     Otherwise, print the value of the error variable.
    import java.util.*;
    public class DateDriver
    Date datevalue;
    public static void main(String[] args)
         Scanner stdIn = new Scanner(System.in);
         while (!xStr.equalsIgnoreCase("q"))
         try
              System.out.println("Enter a date in the form mm/dd ("q" to quit): ";
              value = stdIn.nextLine();
              datevalue = new Date(value);                                                        //instaniate the date object
              System.out.println //print date in numeric format
              System.out.println //print date in alphabetic format
              break;
              catch
              System.out.println("print value of error variable.");
              stdIn.next(); // Invalid input is still in the buffer so flush it.
         } //endloop
         }//end main
    } //end class?
    * Date.java
    * Christine Miller-Lane
    *Overall Requirements
    *Create a class named Date that stores date values and prints out the date in either a pure numeric format or a name
    *and number format (see sample session for format details).
    *Date.java class file
    *????????? Date objects should store the date in two int instance variables &#9472; day and month, and it should include
    *the String instance variable, error, initialized with null.
    *     ?     Implement a 1-parameter Date constructor that receives a dateStr string parameter and performs complete
    *     error checking on the given dateStr value. The Date constructor is the entity that?s responsible for date error
    *     checking. That way, if a Date object is instantiated and if there are no errors, then you?re guaranteed that the
    *     Date object holds a legitimate date value. If any kind of error occurs, change the value of the error instance
    *     variable to a non-null string value, using an appropriate concatenation of a string constant, input substring,
    *     and/or API exception message.?
    *     ?     Constructors use the same exception handling rules as methods: In a try block, include the parsing of the
    *     month and day substrings and other error-checking logic that will not work if parsing fails.
    *????????? Take into account the actual number of days in each month, but assume that there are always 28 days in February.
    *????????? To extract day and month numbers from the given date string, use String?s indexOf method to find the
    *location of the slash character, and String?s substring method to extract month and day substrings from the input string.
    import java.util.*;
    public class Date
         Scanner stdIn = new Scanner(System.in);
         boolean valid = false
         int day;
         int month;
         String error = null;
         String dayStr;
         String monthStr;
         String dateStr;
         public Date(String dateStr)
    // Look for the slash and set appropriate error if one isn't found. use String?s indexOf method to find the
    //location of the slash character and String?s substring method to extract month and day substrings from the input string.
    // Convert month portion to integer. Catch exceptions and set appropriate error if there are any.
    Integer.parseInt(dateStr);
    // Validate month is in range and set appropriate error if it isn't.
    // Convert day portion to integer. Catch exceptions and set appropriate error if there are any.
    // Validate day is in range based on the month (different days per month) and set appropriate error if it isn't.
    //public void printDate()      //Include a method for printing the date with a numeric format. Use the zero-pad flag in a printf method
                                       //call to get exactly two digits for each month and day.
    //{                                   //Include a method for printing the date with an alphabetic format.      
    //     } // end print report
    //     public getError()
                                  //Include a getError method which returns the value of the error instance variable.
    }//end class Date
    Here is sample out put needed::::::::
    Sample Session:
    Enter a date in the form mm/dd ("q" to quit): 5/2
    05/02
    May 2
    Enter a date in the form mm/dd ("q" to quit): 05/02
    05/02
    May 2
    Enter a date in the form mm/dd ("q" to quit): 52
    Invalid date format ? 52
    Enter a date in the form mm/dd ("q" to quit): 5.0/2
    Invalid format - For input string: "5.0"
    Enter a date in the form mm/dd ("q" to quit): 13/2
    Invalid month ? 13
    Enter a date in the form mm/dd ("q" to quit): 2/x
    Invalid format - For input string: "x"
    Enter a date in the form mm/dd ("q" to quit): 2/30
    Invalid day ? 30
    Enter a date in the form mm/dd ("q" to quit): 2/28
    02/28
    February 28
    Enter a date in the form mm/dd ("q" to quit): q
    I am trying to attack this ONE STEP at a time, even though I only have until Sunday at midnight. I will leave this post and get some rest, then attack it again in the morning.
    Edited by: stillTrying on Jul 12, 2008 8:33 PM

    Christine,
    You'r doing well so far... I like your "top down" approach. Rough out the classes, define ALL the methods, especially the public one... but just sketch out the requirements and/or implementation with a few comments. You'll do well.
    (IMHO) The specified design is pretty crappy, especially the Exception handling
    [The Constructor] performs complete error checking on the given dateStr value. The Date constructor is the entity that?s responsible for date error checking. That way, if a Date object is instantiated and if there are no errors, then you?re guaranteed that the Date object holds a legitimate date value. If any kind of error occurs, change the value of the error instance variable to a non-null string value, using an appropriate concatenation of a string constant, input substring, and/or API exception message.Please allow me to shred this hubris piece by piece.
    [The Constructor] performs complete error checking on the given dateStr value. The Date constructor is the entity that?s responsible for date error checking.Umm... Well I suppose it could... but NO, the constructor should delegate such "complex validation" to a dedicated validate (or maybe isValid) method... which might even be made publicly available... it's a good design.
    That way, if a Date object is instantiated and if there are no errors, then you?re guaranteed that the Date object holds a legitimate date value. If any kind of error occurs, change the value of the error instance variable to a non-null string value ...Utter Bollocks! When passed an invalid input string the, Date constructor should throw an InvalidDataException (or similar). It should not SILENTLY set some dodgy error errorMessage attribute, which is returned later by a "print" method. We tried that in masm, fortran, ada, basic, c, and pascal for twenty odd years. It sucked eggs. And it STILL sucks eggs. Java has a "proper" try/catch exception handling mechanism. Use it.
    I mean, think it through...
      someDate = get a date from the user // user enters invalid date, so someDate is null and errMsg is set.
      report = generateReport() // takes (for the sake of argument) three hours.
      emailReport(someDate, report) // only to fail at the last hurdle with an InvalidDataException!And anyways... such implementation details are traditionally the implementors choice... ie: it's usually between the programmer and there tech-manager (if they're lucky enough to have one).
    Cheers. Keith.

  • How to parse string to date with defualt format?

    is there any possibilities to parse a string to date if we don't specify the format in SDF?
    In database we have different formats and we need to convert each one convert to date with common format(something like default), is there any possibilities to do in java?

    jwenting wrote:
    Tolls wrote:
    ColinAtWork wrote:
    SumantK wrote:
    In database we have different formats and we need to convert each one convert to date with common format(something like default), is there any possibilities to do in java?Why don't you store the date in the database as a DATE datatype then you can format anyway you like??Because some people seem to fear DATEs and prefer the supposed comforts of a VARCHAR2...after all, who knows what murky goings on occur with a DATE, but at least a VARCHAR2 is readable, or something like that anyway.Just because some people don't know how to work with DATE fields (which is the real reason for their "fear" doesn't mean you shouldn't use them.
    They're the appopriate solution, so use it.Often but not always true.
    For example neither MS SQL Server nor Oracle timestamp types will store the resolution capable with the Java Date type. So if one wants to maintain all of that resolution one requires either a varchar or two columns.
    And although I haven't been able to confirm it (recently at least) at one time one of the Oracle drivers had a bug that a timestamp would wipe out following columns. For that one either one was left with having only a single timestamp as the last column or using a varchar.

  • JAXB and formating a date

    Hi,
    i have a problem:
    The java-classes generated by JAXB from the following code-snipplet
        <xs:attribute name="edate" use="required">
          <xs:simpleType>
            <xs:restriction base="xs:date"/>
          </xs:simpleType>
        </xs:attribute>produce during marshalling a string like "2000-01-22+01:00".
    How can I suppress the +01:00 (which I assume to be the offset
    from my local timezone to GMT)? Adding a pattern restriction doesn't work.
    Is it possible to modify the DateFormat used by JAXBs internal classes to
    achieve my goal?
    Thanks

    You can define your own conversion for the date inside your XML-Java binding Schema (XJS):
    <xml-java-binding-schema>
    <element name="date"
             type="value"
             convert="ConvertDate"/>
    <conversion name="ConvertDate"
                type="java.util.Date"
                parse="ConvertDate.parse"
                print="ConvertDate.format"/>
    </xml-java-binding-schema>
    ConvertDate contains two methods that help the marshalling and
    unmarshalling process convert to and from java.util.Date.
    import java.util.*;
    import java.text.*;
    public class ConvertDate {
       static final SimpleDateFormat _format =
          new SimpleDateFormat("yyyy.MM.dd");
       public static Date parse(String date)
          throws ParseException {
          synchronized(_format) {
             return _format.parse(date);
       public static String format(Date date) {
          synchronized(_format) {
             return _format.format(date);
    }

  • Data Recovery from Partitioned and formatted Bit Locker Encrypted Drive

    Recently because of some issues in windows 7 installation from windows 8 installed OS. it was giving as the disc is dynamic windows can not be installed on it. so at last after struggling hard no other solution i partitioned and formatted my whole
    drive so all data gone included the drive which was encrypted by bit lockers.
    For recovery i used many software such as ontrack easy recover, get data back, recovery my files professional edition but still i couldnt able to recover my data from that drive. then i found some suggestion Using CMD to decrypt my data first 
    http://technet.microsoft.com/en-us/library/ee523219(WS.10).aspx
    where it shows it successfully decrypt my data at that moment my drives were in RAW format excluding on which windows is installed and then in CMD i check Chdsk which also shows no problem found. but now problem is still i coudnt able to recover
    my data then i format the drive D and again tried to recover data using above software after decryption still no result. 
    Now i need assistance how i can recover my encrypted drive as it was partitioned and also formatted but decrypted also as i have its recovery key too. thanks

    Hi ,
    I am afraid that we cannot get the data back if the drive has been formatted even if use the
    BitLocker Repair Tool.
    You’d better contact your local data recovery center to try to get data back.
    Tracy Cai
    TechNet Community Support

  • I just used stellar phoenix mac data recovery and it seemed to work but now my files won't open.  Even though they are "jpeg, mov" files the error message is  could not be opened. The movie's file format isn't recognized. "  Any help or are they corrupted

    I just used stellar phoenix mac data recovery and it seemed to work but now my files won't open.  Even though they are "jpeg, mov" files, the error message is  "could not be opened". The movie's file format isn't recognized. "  Any help or are they corrupted?

    Sounds to me like the file is probably corrupt. If you had hard drive corruption or damage, that could easily result in recovered files not being fully intact. If you were trying to recover accidentally deleted files, it's possible they might have been partially overwritten before recovering. There are never any guarantees with file recovery.
    Without more information on the circumstances that led you to try recovery, it's hard to give advice on what to try from here. You could always try another file recovery tool, like Data Rescue 3. Just be sure you're taking appropriate precautions when doing recovery. See Recovering deleted files.

  • Conditional format with large data fails and show error as "Selection is too large" in Excel 2007

    I am facing a issue in paste special operation using conditional formats for large data in Excel 2007
    I have uploaded a file at below given location. 
    http://sdrv.ms/1fYC9qE
    The file contains two sheets, Sheet "Data" contains the data on which formats are to be applied and sheet "FormatTables" contains the format tables which contains conditional formating.
    There are two table in "FormatTables" sheet. Both have some conditional formats applied on it. 
    Case 1: 
    1. Select the table range of Table1 i.e $A$2:$AV$2
    2. Copy it
    3. Goto Sheet "Data" 
    4. Select data area i.e $A$1:$AV$20664
    5. Perform a paste special operation on full range and select "Formats" option while performing paste special.
    Result:
    It throws error as "Selection is too large"
    Case 2:
    1. Select the table range of Table2 i.e $A$5:$AV$5
    2. Copy it
    3. Goto Sheet "Data" 
    4. Select data area i.e $A$1:$AV$20664
    5. Perform a paste special operation on full range and select "Formats" option while performing paste special.
    Result:
    Formats get applied successfully.
    Both are the same format tables with same no of column and applied to same data range($A$1:$AV$20664) where one of the case works and another fails.
    The only diffrence is Table1 has appliesTo range($A$2:$T$2) as partial of total table range($A$2:$AV$2) whereas the Table2 has appliesTo range($A$5:$AV$5) same as of its total table range($A$5:$AV$5)
    NOTE : This issue is only in Excel 2007

    Excel 2007 No Supporting formating to take a formatting form another if source table has more then 16000 rows and if you want to do that in more then it then you have ot inset 1 more row in your format table to have 3 rows
    like: A1:AV3
    then try to copy that formating and apply
    Solution Case 1: 
    1.Select the table range of Table1 i.e AV21 and drage it down to one row down
    2. Select the table range of Table1 i.e $A$2:$AV$3
    3. Copy it
    4. Goto Sheet "Data" 
    5. Select data area i.e $A$1:$AV$20664
    6. Perform a paste special operation on full range and select "Formats" option while performing paste special

  • Show Current Date in Year Format (and now - 1, etc.)

    Our form has some column headers that need to change each year, the headings are current year (2010) + previous 3 years.  Am trying to programatically add the titles to eliminate modifying the form just to change the year, but not finding how to accomplish, and was checking out some date samples found, but no success yet.  My question is 2 part - how/where do I put code, I don't need the user to enter anything, just want a column header.  This example below is where I copied the idea from a sample and tried to adjust, it's on the calculate event of a date/time field, and I get an error message that says 'the display pattern "date-{MM/DD]" is incompatible with the object's data format.  Define a compatible Display pattern.  This display pattern error is the 2nd part of the question.  How do I display only the 4 digit year?
    year1.rawValue
    = num2date(date(), "YYYY")
    How do I accomplish this - am newbie on this!  Thank you very much!

A: Show Current Date in Year Format (and now - 1, etc.)

1) I typically use a hidden field to capture the current date on the layout:ready event.
2) If year1 is a date object  your script is valid but you are probably missing the display pattern date{YYYY} on year1.
If year1 is a text field you could could capture current year in a hidden field as
// form1.page1.currentYear::ready:layout - (FormCalc, client)
$.rawValue = Num2Date(Date(), "YYYY")
where currentYear has the display pattern date{YYYY} and add
this.rawValue = form1.page1.currentYear.rawValue;
to the calculate event of year1.
Steve

1) I typically use a hidden field to capture the current date on the layout:ready event.
2) If year1 is a date object  your script is valid but you are probably missing the display pattern date{YYYY} on year1.
If year1 is a text field you could could capture current year in a hidden field as
// form1.page1.currentYear::ready:layout - (FormCalc, client)
$.rawValue = Num2Date(Date(), "YYYY")
where currentYear has the display pattern date{YYYY} and add
this.rawValue = form1.page1.currentYear.rawValue;
to the calculate event of year1.
Steve

  • Date selection and date format in MSSQL

    i have to make a select transaction with a microsoft SQL db. I have to select the entry in a given range of time. So i've made my little form with the datepicker of jquery. The datetime field in the database has this output:
    Jan 1 2014 12:00:00:000AM
    This is the format of the jquery datepicker:
    {dateFormat: 'M dd yy'}
    WHen i receive the GET call (but i've tested even with a POST and the output is the same)from the form i add the hours to the date (I'm using Zend framework 1.12):
    $startdate= $this->getRequest()->getParam('datepicker');
    $startdate= $startdate." 12:00:00:000AM";
    $enddate= $this->getRequest()->getParam('datepicker1');
    $enddate= $enddate." 12:00:00:000AM";
    But it probably is not the right one as my select query:
    SELECT [Document No_],[Sell-to Customer No_],[Planned Delivery Date],[Description],[Description 2] FROM dbo.SyncroPlanningTable WHERE CAST([Planned Delivery Date] as datetime)>='".$startdate."' AND CAST([Planned Delivery Date] as datetime)<='".$enddate."' ORDER BY [Planned Delivery Date] ASC
    doesn't give any output. What am I doing wrong?

    >>Jan 1 2014 12:00:00:000AM
    I am not sure(I am also not so good in Zend,but still would like to give it a shot), should the format be like this?
    Jan 1 2014 12:00:00.000 AM
    Also SQL stores the date in the format YYYY-MM-DD hh:mm:ss.fff(2014-02-12 21:41:00.293). So I think, if you pass the date in that format your query would work fine
    Satheesh
    My Blog |
    How to ask questions in technical forum

  • Data Acqusition and recording in Binary Format

    Hi
    Can anyone tell me how to perform buffered Data acquisition and write
    it in Binary format.
    I want to record data when it is streaming that is i would like to
    record data on a real time basis.
    I have started acquiring data and also graphed it, But it is not a
    buffered acquisition, Can i record this data in the binary format??
    Srikanth

    Hi,
    Labview has an example that does exactly what you are asking for:
    Cont Acq to File (binary).vi
    You'll find it in:
    \examples\daq\anlogin\strmdisk.llb
    Good luck,
    Alberto

  • Maybe you are looking for

    • Itunes 10.6 on Lion and Quicktime 10.1 don´t play bought movies from I tunes store, any ideas why?

      I have issues with Itunes 10.6 on Lion and Quicktime 10.1. They don´t play bought movies from I tunes store, any ideas why?

    • Doubts in the following program about return

      class a public boolean methoda(String ab) String k; k = ab; System.out.println(" methoda in class a " + k); return true; class b extends a public void methoda() System.out.println(" methoda in class b "); public boolean methoda(String he) System.out.

    • All of sudden, images are not loading completely

      It makes no diff if I upload it directly or as a dependent file, all images are only uploading about 20%, then there is a big grey area. I have DW5.5. The pages upload, but the images are not. This is across two web hosts, 3 web sites at least. Help

    • Sql query generator from xml data

      Hi, I am looking for an open source tool in java which would generate the sql query with an xml configuration file as input. The xml configuration file schema would be defined by the tool and and would provide placeholders for giving the various info

    • Passing parameter from JSpx to Jsff

      Hi , I am trying to create left menu panel using jsff and i am putting in a page .So I want to pass some parameter from jspx to jsff .Please let me know how can i achive ??