Formatter issue

I have a strange issue at hand. I am trying to apply a formatter to format date to one of the fields but the formatter function never gets invoked.
I tried with XMl and JS views but non of them seems to work is there any trick I am missing.
I am also using lazy loading because I thought eager loding of views might be issue but no use.
Here is code in contention
var oTemplate = new sap.m.ColumnListItem({
  type:"Navigation",
  press:oController.handleProjectSelected,
  cells:[
        new sap.m.ObjectIdentifier({title:"{displayName}"}),
        new sap.m.Text({
        path:"creationDate",
        formatter:"util.Formatter.date"
        new sap.m.Label({
        text:"{creatorUserName}"
        new sap.m.Text({
        path:"lastDataUpdateDate",
        formatter:"util.Formatter.date"
//Same for XML view
<ColumnListItem
  type="Navigation"
  press="handleProjectSelected">
  <cells>
  <ObjectIdentifier title="{displayName}"/>
  <Text text="{
  path:'creationDate',
  formatter:'util.Formatter.date'
  }"/>
  <Text text="{creatorUserName}"/>
  <Text text="{
  path:'lastDataUpdateDate',
  formatter:'util.Formatter.date'
  }"/>
  </cells>
  <customData>
  <core:CustomData
  key="target"
  value="Project"/>
  </customData>
  </ColumnListItem>
Here is Formatter code it never gets invoked
jQuery.sap.declare("util.Formatter");
jQuery.sap.require("sap.ui.core.format.DateFormat");
util.Formatter = {
  date : function (value) {
  if (value) {
  var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern: "yyyy-MM-dd"});
  return oDateFormat.format(new Date(value));
  } else {
  return value;

Hi,
Since you can specify a formatter for basically any attribute, you should also specify for which attribute you want tho use a formatter.
For instance, the following code uses a formatter for both 'text' and 'valueState' properties:
var oTV = new sap.ui.commons.TextView({
    text: {
        parts: ["mydatefield"],
        formatter: function(oValue) {
            if (oValue != undefined) {
                var yyyy = oValue.getFullYear().toString();
                var mm = (oValue.getMonth() + 1).toString(); // getMonth() is zero-based        
                var dd = oValue.getDate().toString();
                return yyyy + '/' + (mm[1] ? mm : "0" + mm[0]) + '/' + (dd[1] ? dd : "0" + dd[0]);
            } else return "";
    valueState: {
        parts: ["mydatefield"],
        formatter: function(oValue) {
            return (oValue === undefined || oValue == null) ? sap.ui.core.ValueState.Error : sap.ui.core.ValueState.None;
Hope this explains!
R.

Similar Messages

  • EA1 - SQL Formatter issues (JOINs and GROUPs and ORDER BY oh my ;)

    Great job with improving the SQL Formatter, but it still has some bugs that need to be worked out.
    The key words JOIN and it's modifiers INNER, LEFT, RIGHT and FULL OUTER are not recognized as master key words. As such they end up flush against the left margin Also when GROUP BY and/or ORDER BY key words are present in an outer most select statement the other key words are not indented far enough to be right aligned with the end of the word BY and are indented too far to be right aligned with the word GROUP or ORDER. In sub queries, GROUP and ORDER BY are correctly right aligned with their respective SELECT statements.

    We're picking up and collating the Formatter issues. I'll add these.
    Specific bug for these #7013462
    Sue

  • EA1: A few formatter issues

    1. Alignment of AND keywords in select statement is wrong.
      function get_segment_size(ownname in varchar2,   segname in varchar2, segtype in varchar2) return number is indsize number(16);
      begin
        begin
          select bytes
          into indsize
          from dba_segments
          where owner = ownname
           and segment_type = segtype
           and segment_name = segname;
        exception
        when others then
          raise;
        end;
        return indsize;
      end;becomes
    FUNCTION get_segment_size
        ownname IN VARCHAR2,
        segname IN VARCHAR2,
        segtype IN VARCHAR2 )
      RETURN NUMBER
    IS
      indsize NUMBER ( 16 ) ;
    BEGIN
      BEGIN
         SELECT bytes
           INTO indsize
           FROM dba_segments
          WHERE owner  = ownname
      AND segment_type = segtype
      AND segment_name = segname;
      EXCEPTION
      WHEN OTHERS THEN
        raise;
      END;
      RETURN indsize;
    END;The ANDs are left aligned with the enclosing block rather than right aligned with the 'master keywords'.
    2. NUMBER(?,?) and VARCHAR2(?) declarations have parentheses and sizes split over multiple lines.
      index_list dba_indexes_tab;
      rebuild_stmt varchar2(200);
      end_time date;
      start_size number(16,   0);
      end_size number(16,   0);
      batch app_support_batch_runs % rowtype;
      batch_results resultset;becomes
      index_list dba_indexes_tab;
      rebuild_stmt VARCHAR2
        200
      end_time DATE;
      start_size NUMBER
        16, 0
      end_size NUMBER
        16, 0
      batch app_support_batch_runs % rowtype;
      batch_results resultset;3. Some array subscripted expressions have their parentheses split across multiple lines.
        end_time := sysdate;
        batch_results := resultset();
        batch_results.extend;
        batch_results(batch_results.last).asjr_result_type := 'ELAPSED_TIME';
        batch_results(batch_results.last).asjr_result_key := 'ALL';
        batch_results(batch_results.last).asjr_result_value :=((end_time -batch.asbr_component_start_time) *(24 *60 *60));becomes
      end_time      := sysdate;
      batch_results := resultset
      batch_results.extend;
      batch_results
        batch_results.last
      .asjr_result_type := 'ELAPSED_TIME';
      batch_results
        batch_results.last
      .asjr_result_key := 'ALL';
      batch_results
        batch_results.last
      .asjr_result_value :=
        ( end_time -batch.asbr_component_start_time ) * ( 24 *60 *60 )
      ;Another similar block later in the same package is left as single lines.
    4. 3 seems to apply generally to expressions involving parentheses - array subscripts, procedure calls. Some are done properly, others are spread across multiple lines.
    5. Various keywords are not recognised by the formatter, although they are by the syntax highlighter. (They are in bold, but not upper case)
    raise
    extend
    last
    immediate
    6. There doesn't seem to be away to format the current selection rather than the whole buffer (in the PL/SQL editor)

    Given this -
    select prej.asbr_component_name,
      prej.asbr_batch_start_time,
      etime.asjr_result_value Elapsed,
      prer.asjr_result_value Size_before,
      postr.asjr_result_value Size_after,
      prer.asjr_result_value -postr.asjr_result_value Shrinkage
    from app_support_batch_runs prej
    inner join app_support_job_result prer on prer.asjr_asbr_id = prej.asbr_id
    inner join app_support_job_result postr on postr.asjr_asbr_id = prej.asbr_id
    inner join app_support_job_result etime on etime.asjr_asbr_id = prej.asbr_id
    where prer.asjr_result_type = 'START_SIZE'
    and postr.asjr_result_type = 'END_SIZE'
    and etime.asjr_result_type = 'ELAPSED_TIME'
    order by prej.asbr_component_name;with [em]indent AND/OR[em] unchecked, you get this.
    SELECT prej.asbr_component_name    ,
      prej.asbr_batch_start_time        ,
      etime.asjr_result_value Elapsed   ,
      prer.asjr_result_value Size_before,
      postr.asjr_result_value Size_after,
      prer.asjr_result_value -postr.asjr_result_value Shrinkage
       FROM app_support_batch_runs prej
    INNER JOIN app_support_job_result prer
         ON prer.asjr_asbr_id = prej.asbr_id
    INNER JOIN app_support_job_result postr
         ON postr.asjr_asbr_id = prej.asbr_id
    INNER JOIN app_support_job_result etime
         ON etime.asjr_asbr_id    = prej.asbr_id
      WHERE prer.asjr_result_type = 'START_SIZE'
    AND postr.asjr_result_type    = 'END_SIZE'
    AND etime.asjr_result_type    = 'ELAPSED_TIME'
    ORDER BY prej.asbr_component_name;The problems with this are.
    1) The sql statement as a whole is indented (ie the select keyword)
    2) Despite 1), INNER, AND and ORDER are NOT indented at all whereas the should be at least level with the select. I suspect the problem may be that it is trying to right align 'INNER JOIN' and 'ORDER BY' with the SELECT-FROM-WHERE.I thing the ON of the join clauses is right aligned.
    3) The column list isn't right. The columns should be left aligned and positioned one space to the right of the select keyword ( or at a pinch on a new line, indented from the select keyword by 2 columns)
    with [em]indent AND/OR[em] checked, you get this.
    SELECT prej.asbr_component_name    ,
      prej.asbr_batch_start_time        ,
      etime.asjr_result_value Elapsed   ,
      prer.asjr_result_value Size_before,
      postr.asjr_result_value Size_after,
      prer.asjr_result_value -postr.asjr_result_value Shrinkage
       FROM app_support_batch_runs prej
    INNER JOIN app_support_job_result prer
         ON prer.asjr_asbr_id = prej.asbr_id
    INNER JOIN app_support_job_result postr
         ON postr.asjr_asbr_id = prej.asbr_id
    INNER JOIN app_support_job_result etime
         ON etime.asjr_asbr_id    = prej.asbr_id
      WHERE prer.asjr_result_type = 'START_SIZE'
      AND postr.asjr_result_type  = 'END_SIZE'
      AND etime.asjr_result_type  = 'ELAPSED_TIME'
    ORDER BY prej.asbr_component_name;This is better but still has the problems with right-alignment.
    With [em]Right-align master keywords[em] unchecked...
    SELECT prej.asbr_component_name     ,
      prej.asbr_batch_start_time        ,
      etime.asjr_result_value Elapsed   ,
      prer.asjr_result_value Size_before,
      postr.asjr_result_value Size_after,
      prer.asjr_result_value -postr.asjr_result_value Shrinkage
    FROM app_support_batch_runs prej
    INNER JOIN app_support_job_result prer
    ON prer.asjr_asbr_id = prej.asbr_id
    INNER JOIN app_support_job_result postr
    ON postr.asjr_asbr_id = prej.asbr_id
    INNER JOIN app_support_job_result etime
    ON etime.asjr_asbr_id        = prej.asbr_id
    WHERE prer.asjr_result_type  = 'START_SIZE'
      AND postr.asjr_result_type = 'END_SIZE'
      AND etime.asjr_result_type = 'ELAPSED_TIME'
    ORDER BY prej.asbr_component_name;IMO This is best but I would like ON indented with respect to the INNER JOIN it belongs to.
    So in terms of this sql statement, I think the only bug is the alignment of columns. The right alignment option doesn't work very well for longer 'keywords' (mainly the new-fangled sql-92 stuff). Perhaps a redefinition of what constitutes a master keyword would do better.

  • EA2: Formatter issues

    1) Formatter in the worksheet doesn't leave a blank line between sql statements.
    If you have several statements in worksheet and format them, they are all formatted as one with no gap between them.
    2) You can't just format the selection. If I select a statement and format, the whole worksheet is formatted.
    3) It doesn't handle syntax errors.
    I think the formatter should detect and report syntax errors (it is a parser after all).
    In my worksheet, one of the statements had a syntax error (semi colon inside the parentheses of a sub-query instead of outside), and later statements in the worksheet are indented relative to the statement with the error. AFAICS, the subsequent statements are formatted correctly, but the left margin isn't reset after the error statement.

    I agree with smitjb's statements. The formatter has other flaws as well like:
    1) Columns and tables are simply indented based on the indentation setting rather than left aligned 1 space after the leading SELECT
    2) [INNER, LEFT, RIGHT, FULL [OUTER]] JOIN statements are not right aligned with the select key word the same was as the FROM and WHERE key words
    3) GROUP BY and ORDER BY are not aligned with the SELECT key word on the space between GROUP/ORDER and BY, alternatively, the SELECT, FROM and WHERE key words are not indented suffciently to right align with the BY key word.
    Setting the formatter indent to 8 cause columns and table to line up 1 space to the right of the SELECT statement, but then nesting of PL/SQL statements shifts to the right very quickly. Perhaps these could be separate indents.
    Selecting the option to have a line break follow select from and where statements is not preserved so is not honored.

  • TOC formattting issue

    I've been using framemaker for over 10 years, and I have a nagging problem in TOC's.
    Give that you want standard toc's such as:
    1.1 Introduction........................................1.3
    Simply put, when you generate your TOC in a  book, there may be times when the "paratext" is quite long and it causes the text to get to close to the page number or even wraps over to the next line.
    For example:
    1.1 Introduction to Framemaker 9.0 basics1.3
    1.1 The small brown fox jumped over the b
          arrel1.1
    How can we set up the heading1TOC parastyle to maintain a distance from the page number and if the paratext is to long, wrap to the next line and put the page number on the far right side.
    my basic heading1toc style is set as follows:
    Tab stops: 1.375 left
                     6.25 right (with leader ....)
    on the reference pages,  the heading1toc is
    <$paranum> <$paratext>.................<$pagenum>
    How can I set it to always "wrap" the text, say for example, when it reachs 6.00 inch so the above example would result in
    1.1 Introduction to Framemaker 9.0 basics...1.3
    1.1 The small brown fox jumped over the b
          arrel....................................................1.3
    Anybody have a solution?

    Archive guy wrote:
    I've been using framemaker for over 10 years, and I have a nagging problem in TOC's.
    Give that you want standard toc's such as:
    1.1 Introduction........................................1.3
    Simply put, when you generate your TOC in a  book, there may be times when the "paratext" is quite long and it causes the text to get to close to the page number or even wraps over to the next line.
    For example:
    1.1 Introduction to Framemaker 9.0 basics1.3
    1.1 The small brown fox jumped over the b
          arrel1.1
    How can we set up the heading1TOC parastyle to maintain a distance from the page number and if the paratext is to long, wrap to the next line and put the page number on the far right side.
    my basic heading1toc style is set as follows:
    Tab stops: 1.375 left
                     6.25 right (with leader ....)
    on the reference pages,  the heading1toc is
    <$paranum> <$paratext>.................<$pagenum>
    How can I set it to always "wrap" the text, say for example, when it reachs 6.00 inch so the above example would result in
    1.1 Introduction to Framemaker 9.0 basics...1.3
    1.1 The small brown fox jumped over the b
          arrel....................................................1.3
    Anybody have a solution?
    This is an often-posted question. You can find past solutions with aGoogle search for "framemaker toc wrap long lines" and similar phrases, without quotes.
    HTH
    Regards,
    Peter Gold
    KnowHow ProServices

  • Decimal formatter issue

    Hi All,
    In a datagrid I use labelFunction method to format input numbers, this function will format decimal numbers with precision 2.
    public static function formatDecimal(val:Number):String
                var decimalFormatter: NumberFormatter = new NumberFormatter();
                decimalFormatter.rounding = "up";
                decimalFormatter.precision = 2;
                decimalFormatter.useNegativeSign = false;
                return decimalFormatter.format(val);
    Now, if the input is 2.55 only, it format the number to 2.56. It is a way to prevent this?
    It should format 2.56 if the input is 2.555. correct?
    Thanks
    JFB

    This is strange, it happens only with 8.55, it converts to 8.56 but my total calculations on the grid is reading 8.55 not 8.56.
    Is not doing the same for 2.55, 3.55 or 4.55
    Any ideas? Is this a bug?
    Thanks!
    JFB

  • Help needed with referencing single Excel cells and formatting resulting text

    In InDesign CS5 I am putting together a 20pp catalogue of about 200 products. The plan is to have the product information, SKU code, quantity etc fixed, but have the prices (there are two i.e. pack price and individual price) being linked to an Excel spreadsheet. This is so that the prices can be updated in the Excel file and the InDesign file will pull the new prices through. In case you are wondering why I don't pull the whole set of information through, this is because there are a lot of copywriting changes done to the information once it's in InDesign - it's only going to be the prices that will be updated.
    I am planning on having two single cell tables in their own text frame, duly formatted with cell style, table style and paragraph style for the two price variables. This I am then going to have to repeat 200 times making sure I link to the next row down in Excel. This is going to be a hideous task but I see know way of modifying the cell in InDesign to point it to the next row in Excel. That's my first problem.
    My second problem is this. In the Excel sheet, the prices are formatted as UK currency and are therefore like this...
    £2.00
    £0.40
    £1.43
    £9.99
    £0.99
    £0.09
    What I will require is once I import that data (and refresh the data via a newly saved Excel file) is that the prices end up like this...
    £2.00
    40p
    £1.43
    £9.99
    99p
    9p
    So if the value is lower than £1.00 it needs a trailing 'p' added  and the leading zero and '£' sign stripped off. If the value is lower than £0.10 it also needs the zero after the decimal point stripping off.
    Then formatting wise, the '£' sign needs to be superscripted and the same for the 'p'. This I am assuming could be done via GREP?
    In summary, can anyone help with the first task of referecing the Excel cells on a cell by cell basis, given that it is the same cell column each time, but the next row down, and also point me in the right direction of the price formattting issues.
    Any help will be gratefully received.

    I would do this:
    Create on line with the formatting.
    Export as InDesign tagged text (TXT)
    Read out these tags
    In Excel exists a function to connect text from several cells and predfined text, there connect the content from cells with the paragraph styling tags. Do it in a seperate sheet. (Better would be to use a database like Access, there you can link your Excel sheet).
    Export this sheet as txt file
    Place this sheet as tagged text (there is an option in one of the sialog boxes).
    In preferences  < file handling you can specify that Tablecalculation Sheets and text is not embedded but linked, turn it on.

  • Manual formatted for C: and D: drive Via SCCM 2012 task sequence

    Dear All
    i have a problem with the formatting of the HDD by using SCCM 2012 , our Co. have laptops with C: &
    D: drive and we started to implement our W7 migration by using SCCM 2012 and we face the a problem which is how to keep the data of the D drive either during the deploy the new W 7 image our after we deployed the image with C and D drive .
    we create a task sequence to format the whole HDD and then make two partition .
    but our target to keep the old users data in D: drive in case of system crash .
    so can we do the format issue manually via  task sequence to can control the size of the HDD and just
    format the C: drive
    i read in internet there is a Disk partition script can be apply during the task sequence activity to control
    the formate issue.
    or to stop the formatte issue for D: drive via SCCM.

    Dear  EminM
    thanks
    for your replay 
    you are right i mean the laptop has C and D partition 
    we make a TS which was  configure to crate two partition 
    After we complete our Task sequence we face problem that TS format the two partition and that mean  we will loss the data in D partition in case we need to apply this TS in the future to any laptop has system crash .
    our target to have TS just format the C partition and leave the D partition without any action to be able to save the data in the D partition without any corrupted.
    for that do you have an idea to do that TS .

  • 2.1 Final - Another Minor Formatter Indentation Issue

    Looks like when you're declaring functions in a package, that it indents them when it shoudln't be, and causes a shift in following lines.
    Example:
    CREATE OR REPLACE
    PACKAGE pkg
    AS
    PROCEDURE p1;
    PROCEDURE p2;
      FUNCTION f1
        RETURN NUMBER;
      FUNCTION f2
        RETURN NUMBER;
      PROCEDURE p3;
      END pkg; Should be:
    CREATE OR REPLACE
    PACKAGE pkg
    AS
    PROCEDURE p1;
    PROCEDURE p2;
    FUNCTION f1
      RETURN NUMBER;
    FUNCTION f2
      RETURN NUMBER;
    PROCEDURE p3;
    END pkg;

    Hi Marwim,
    Thanks for this feedback.
    I have replicated the issue and logged a bug.
    Bug 9231534 - FORUM:USER DEFINED REPORT FOLDER MISSING ACTIONS IN NON ENGLISH LOCALES
    Regards,
    Dermot
    SQL Developer Team

  • Performance issues with version enable partitioned tables?

    Hi all,
    Are there any known performance issues with version enable partitioned tables?
    I’ve been doing some performance testes with a large version enable partitioned table and it seems that OCB optimiser is choosing very expensive plans during merge operations.
    Tanks in advance,
    Vitor
    Example:
         Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
    UPDATE STATEMENT Optimizer Mode=CHOOSE          1          249                    
    UPDATE     SIG.SIG_QUA_IMG_LT                                   
    NESTED LOOPS SEMI          1     266     249                    
    PARTITION RANGE ALL                                   1     9
    TABLE ACCESS FULL     SIG.SIG_QUA_IMG_LT     1     259     2               1     9
    VIEW     SYS.VW_NSO_1     1     7     247                    
    NESTED LOOPS          1     739     247                    
    NESTED LOOPS          1     677     247                    
    NESTED LOOPS          1     412     246                    
    NESTED LOOPS          1     114     244                    
    INDEX RANGE SCAN     WMSYS.MODIFIED_TABLES_PK     1     62     2                    
    INDEX RANGE SCAN     SIG.QIM_PK     1     52     243                    
    TABLE ACCESS BY GLOBAL INDEX ROWID     SIG.SIG_QUA_IMG_LT     1     298     2               ROWID     ROW L
    INDEX RANGE SCAN     SIG.SIG_QUA_IMG_PKI$     1          1                    
    INDEX RANGE SCAN     WMSYS.WM$NEXTVER_TABLE_NV_INDX     1     265     1                    
    INDEX UNIQUE SCAN     WMSYS.MODIFIED_TABLES_PK     1     62                         
    /* Formatted on 2004/04/19 18:57 (Formatter Plus v4.8.0) */                                        
    UPDATE /*+ USE_NL(Z1) ROWID(Z1) */sig.sig_qua_img_lt z1                                        
    SET z1.nextver =                                        
    SYS.ltutil.subsversion                                        
    (z1.nextver,                                        
    SYS.ltutil.getcontainedverinrange (z1.nextver,                                        
    'SIG.SIG_QUA_IMG',                                        
    'NpCyPCX3dkOAHSuBMjGioQ==',                                        
    4574,                                        
    4575                                        
    4574                                        
    WHERE z1.ROWID IN (
    (SELECT /*+ ORDERED USE_NL(T1) USE_NL(T2) USE_NL(J2) USE_NL(J3)
    INDEX(T1 QIM_PK) INDEX(T2 SIG_QUA_IMG_PKI$)
    INDEX(J2 WM$NEXTVER_TABLE_NV_INDX) INDEX(J3 MODIFIED_TABLES_PK) */
    t2.ROWID
    FROM (SELECT /*+ INDEX(WM$MODIFIED_TABLES MODIFIED_TABLES_PK) */
    UNIQUE VERSION
    FROM wmsys.wm$modified_tables
    WHERE table_name = 'SIG.SIG_QUA_IMG'
    AND workspace = 'NpCyPCX3dkOAHSuBMjGioQ=='
    AND VERSION > 4574
    AND VERSION <= 4575) j1,
    sig.sig_qua_img_lt t1,
    sig.sig_qua_img_lt t2,
    wmsys.wm$nextver_table j2,
    (SELECT /*+ INDEX(WM$MODIFIED_TABLES MODIFIED_TABLES_PK) */
    UNIQUE VERSION
    FROM wmsys.wm$modified_tables
    WHERE table_name = 'SIG.SIG_QUA_IMG'
    AND workspace = 'NpCyPCX3dkOAHSuBMjGioQ=='
    AND VERSION > 4574
    AND VERSION <= 4575) j3
    WHERE t1.VERSION = j1.VERSION
    AND t1.ima_id = t2.ima_id
    AND t1.qim_inf_esq_x_tile = t2.qim_inf_esq_x_tile
    AND t1.qim_inf_esq_y_tile = t2.qim_inf_esq_y_tile
    AND t2.nextver != '-1'
    AND t2.nextver = j2.next_vers
    AND j2.VERSION = j3.VERSION))

    Hello Vitor,
    There are currently no known issues with version enabled tables that are partitioned. The merge operation may need to access all of the partitions of a table depending on the data that needs to be moved/copied from the child to the parent. This is the reason for the 'Partition Range All' step in the plan that you provided. The majority of the remaining steps are due to the hints that have been added, since this plan has provided the best performance for us in the past for this particular statement. If this is not the case for you, and you feel that another plan would yield better performance, then please let me know and I will take a look at it.
    One suggestion would be to make sure that the table was been recently analyzed so that the optimizer has the most current data about the table.
    Performance issues are very hard to fix without a reproducible test case, so it may be advisable to file a TAR if you continue to have significant performance issues with the mergeWorkspace operation.
    Thank You,
    Ben

  • Issue with Ftp Client / Server using Sockets

    I have developed a Ftp Client and a Ftp Server. The client Connects to the Ftp Server and sends files to the ftp server. It is a multi threaded server and can have multiple clients connecting to it.
    If a client goes down...the server waits till the client comes up
    Similarly the client waits if a server goes down and reconnects when the server is again up and running
    i am having a strange issue here. When two clients go down and reconnect to the server...They take a long time to connect and transferring of files takes a long time...
    Other wise in all other scenarios the duo work properly.
    Any feedback and suggestion about this strange issue from all you java gurus out there will be deeply appreciated.
    Here is the client code
    import java.net.*;
    import java.net.Socket;
    import java.net.InetAddress;
    import java.io.*;
    import java.io.File;
    import java.util.*;
    import java.lang.*;
    import java.lang.Object;
    import javax.crypto.*;
    import java.util.regex.*;
    import javax.crypto.spec.PBEKeySpec;
    import javax.crypto.spec.PBEParameterSpec;
    import java.security.spec.AlgorithmParameterSpec;
    import java.security.spec.KeySpec;
    import java.io.InputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    import java.io.File.*;
    import java.nio.channels.FileLock;
    public class  FTPClient {
         public static void main(String[] args) throws Exception
              Timer timer = new Timer("Test Timer");
              timer.scheduleAtFixedRate(new TimerTask()
                   private int counter = 0;
                                            public void run() {
                                                                     try     {                                                                                
                                                                              System.out.println(counter++);
                                                                               Socket soc=new Socket("xxx.x.x.xx",5217);
                                                                               System.out.println("Socket Initialised.");          
                                                                               transferfileClient t=new transferfileClient(soc);
                                                                               t.SendFile();
                                                                               System.out.println("run complete.");                                                                           
                                                                          catch(Exception ex)
                                                           }, 10000, 40000);
         static class transferfileClient
         Socket ClientSoc;
         DataInputStream din;
         DataOutputStream dout;
         BufferedReader br;
         transferfileClient(Socket soc)
              try
                   ClientSoc=soc;
                   din=new DataInputStream(ClientSoc.getInputStream());
                   dout=new DataOutputStream(ClientSoc.getOutputStream());
                   br=new BufferedReader(new InputStreamReader(System.in));
              catch(Exception ex)
         //encrypto routine starts
    class DesEncrypter {
           Cipher ecipher;
            Cipher dcipher;   
            // 8-byte Salt
            byte[] salt = {
                (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
                (byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03
            // Iteration count
            int iterationCount = 19;   
            DesEncrypter(String passPhrase) {
                try {
                             // Create the key
                             KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
                             SecretKey key = SecretKeyFactory.getInstance(
                             "PBEWithMD5AndDES").generateSecret(keySpec);
                             ecipher = Cipher.getInstance(key.getAlgorithm());
                             dcipher = Cipher.getInstance(key.getAlgorithm());   
                             // Prepare the parameter to the ciphers
                             AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);   
                             // Create the ciphers
                             ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
                             dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
                } catch (java.security.InvalidAlgorithmParameterException e) {
                } catch (java.security.spec.InvalidKeySpecException e) {
                } catch (javax.crypto.NoSuchPaddingException e) {
                } catch (java.security.NoSuchAlgorithmException e) {
                } catch (java.security.InvalidKeyException e) {
            // Buffer used to transport the bytes from one stream to another
            byte[] buf = new byte[1024];   
            public void encrypt(InputStream in, OutputStream out) {
                try {
                    // Bytes written to out will be encrypted
                    out = new CipherOutputStream(out, ecipher);   
                    // Read in the cleartext bytes and write to out to encrypt
                    int numRead = 0;
                    while ((numRead = in.read(buf)) >= 0) {
                        out.write(buf, 0, numRead);
                    out.close();
                } catch (java.io.IOException e) {
            public void decrypt(InputStream in, OutputStream out) {
                try {
                    // Bytes read from in will be decrypted
                    in = new CipherInputStream(in, dcipher);   
                    // Read in the decrypted bytes and write the cleartext to out
                    int numRead = 0;
                    while ((numRead = in.read(buf)) >= 0) {
                        out.write(buf, 0, numRead);
                    out.close();
                } catch (java.io.IOException e) {
    }     //encryptor routine ends     
         void SendFile() throws Exception
                   try
                   String directoryName; 
                   // File object referring to the directory.
                   String[] files;        // Array of file names in the directory.        
                   //directory = new File ( "C:\\FTP\\" ) ; 
                   File directory1 = new File("C:\\FTP");
                        boolean successmk = directory1.mkdir();
                        if (!successmk) {
                             // Directory creation failed /Already Exists
                        File directory = new File("C:\\FTP\\ftpc");
                        boolean successmk1 = directory.mkdir();
                        if (!successmk1) {
                             // Directory creation failed /Already Exists
                   //directory = new File ( "E:\\FTP-encrypted" ) ;           
                if (directory.isDirectory() == false) {
                    if (directory.exists() == false)
                       System.out.println("There is no such directory!");
                    else
                      System.out.println("That file is not a directory.");
                else {
                    files = directory.list();
                    System.out.println("Files in directory \"" + directory + "\":");
                    for (int i = 0; i < files.length; i++)
                             String patternStr = "xml";
                             Pattern pattern = Pattern.compile(patternStr);
                             Matcher matcher = pattern.matcher(files);
                             boolean matchFound = matcher.find();
                                       if (matchFound) {                                   
                                       System.out.println(" " + files[i]);                                        
                                       String filename;
                                       filename=files[i];                                   
                                       File f=new File(directory,filename);
                                       FileLock lock = null;                                   
                                       FileOutputStream fos = new FileOutputStream(f, true);
                                       lock = fos.getChannel().tryLock();
                                                 if (lock == null) {
                                                 System.out.println(" Failed to get the file lock: means that the file is locked by other instance.");
                                                 fos.close();
                                                 else
                                                                     InetAddress addr = InetAddress.getLocalHost();                                                                      
                                                                               // Get IP Address
                                                                               //byte[] ipAddr = addr.getAddress();
                                                                               String ip= addr.toString();                                                                      
                                                                               // Get hostname
                                                                               //String hostname = addr.getHostName();
                                       System.out.println(" Lock Acquired.");
                                       lock.release();
                                       fos.close();
                                       dout.writeUTF("SEND");
                                            dout.writeUTF(ip);
                                       dout.writeUTF(filename);
              //String msgFromServer=din.readUTF();          
    DesEncrypter encrypter = new DesEncrypter("My Pass Phrase!");
    // Encrypt
              FileInputStream fino=new FileInputStream(f);
              encrypter.encrypt(fino,
    new FileOutputStream("ciphertext.txt"));               
              fino.close();
              FileInputStream fin=new FileInputStream("ciphertext.txt");          
              int ch;
              do
                   ch=fin.read();
                   dout.writeUTF(String.valueOf(ch));
              while(ch!=-1);
              fin.close();          
              String option;
                        option=din.readUTF();
                             if((option.compareTo("Delete")==0))     
                                  boolean success = (new File("ciphertext.txt")).delete();
                                  boolean success1 = f.delete();
                                  if (success) {
                                  System.out.println("File Sent ...");
                                  if (success1) {
                                  System.out.println("--File deleted from Client ...");
         for (int j = 0; j < 999999999; j++){}
                                       }//pattermatch loop ends here
    else
                             { //System.out.println("   " + "Not an XML file-------->" +files[i]);
    for (int jb = 0; jb < 111999999; jb++){}
              }// for loop ends here for files in directory
                   }//else loop ends for directory files listing               
         System.out.println("sendfile finished...");
         return;
         }               catch(Exception ex)          {ex.printStackTrace();}                    
         }//sendfile ends here     
         public void displayMenu() throws Exception
                   System.out.println(" Send File");                    
                        SendFile();
                        return;          
    And here is the server code...
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.util.Date;
    import java.text.SimpleDateFormat;
    import java.text.DateFormat;
    import java.text.Format;
    import java.lang.Object;
    import java.lang.*;
    import javax.crypto.*;
    import javax.crypto.spec.PBEKeySpec;
    import javax.crypto.spec.PBEParameterSpec;
    import java.security.spec.AlgorithmParameterSpec;
    import java.security.spec.KeySpec;
    public class FTPServer
    {     public static void main(String args[]) throws Exception
         {     ServerSocket soc=new ServerSocket(5217);
              System.out.println("FTP Server Started on Port Number 5217");
              while(true)
                   System.out.println("Waiting for Connection ...");
                   transferfile t=new transferfile(soc.accept());               
    class transferfile extends Thread
         Socket ClientSoc;
         DataInputStream din;
         DataOutputStream dout;     
         transferfile(Socket soc)
         {     try
              {     ClientSoc=soc;                              
                   din=new DataInputStream(ClientSoc.getInputStream());
                   dout=new DataOutputStream(ClientSoc.getOutputStream());
                   System.out.println("FTP Client Connected ...");
                   System.out.println("External IP of Client ..." + ClientSoc.getInetAddress());
                   //System.out.println("FTP Client Connected ..." + ClientSoc.getRemoteSocketAddress());
                   start();               
              catch(Exception ex)
    //encrypto routine starts
    class DesEncrypter {
            Cipher ecipher;
            Cipher dcipher;   
            // 8-byte Salt
            byte[] salt = {
                (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
                (byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03 };   
            // Iteration count
            int iterationCount = 19;   
           DesEncrypter(String passPhrase) {
                try {
                    // Create the key
                    KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
                    SecretKey key = SecretKeyFactory.getInstance(
                        "PBEWithMD5AndDES").generateSecret(keySpec);
                    ecipher = Cipher.getInstance(key.getAlgorithm());
                    dcipher = Cipher.getInstance(key.getAlgorithm());   
                    // Prepare the parameter to the ciphers
                    AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);   
                    // Create the ciphers
                    ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
                    dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
                } catch (java.security.InvalidAlgorithmParameterException e) {
                } catch (java.security.spec.InvalidKeySpecException e) {
                } catch (javax.crypto.NoSuchPaddingException e) {
                } catch (java.security.NoSuchAlgorithmException e) {
                } catch (java.security.InvalidKeyException e) {
            // Buffer used to transport the bytes from one stream to another
            byte[] buf = new byte[1024];   
            public void encrypt(InputStream in, OutputStream out) {
                try {
                    // Bytes written to out will be encrypted
                    out = new CipherOutputStream(out, ecipher);   
                    // Read in the cleartext bytes and write to out to encrypt
                    int numRead = 0;
                    while ((numRead = in.read(buf)) >= 0) {
                        out.write(buf, 0, numRead);
                    out.close();
                } catch (java.io.IOException e) {
            public void decrypt(InputStream in, OutputStream out) {
                try {
                    // Bytes read from in will be decrypted
                    in = new CipherInputStream(in, dcipher);   
                    // Read in the decrypted bytes and write the cleartext to out
                    int numRead = 0;
                    while ((numRead = in.read(buf)) >= 0) {
                        out.write(buf, 0, numRead);
                        //added later on
                        in.close();                    
                    out.close();
                } catch (java.io.IOException e) {
    }     //encryptor routine ends
    //not implemented right now as we arent using the ftp server to download stuff...can be activated later on if we want
         void SendFile() throws Exception
              String filename=din.readUTF();
              File f=new File(filename);
              if(!f.exists())
                   dout.writeUTF("File Not Found");
                   return;
              else
              {     dout.writeUTF("READY");
                   FileInputStream fin=new FileInputStream(f);
                   int ch;
                   do
                        ch=fin.read();
                        dout.writeUTF(String.valueOf(ch));
                   while(ch!=-1);     
                   fin.close();     
                   dout.writeUTF("File Received Successfully");                                   
         String Compare(String filename) throws Exception
                        ///dout.writeUTF("entering compare");
                        String dateTempString=new String();
                        Date dateValue=new Date();
                        SimpleDateFormat formatter = new SimpleDateFormat ("hhmmss");
                        dateTempString = formatter.format(dateValue);
                        File dir1 = new File("C:\\FTPnew");
                        boolean success2 = dir1.mkdir();
                        if (!success2) {
                             // Directory creation failed /Already Exists
                        File dir = new File("C:\\FTPnew\\server");
                        boolean success = dir.mkdir();
                        if (!success) {
                             // Directory creation failed /Already Exists
                        File ftemp=new File(dir,dateTempString + filename);
                        File fnewtemp=new File(dir,"new-enc-"+filename);
                        // Create encrypter/decrypter class
                        DesEncrypter encrypter = new DesEncrypter("My Pass Phrase!");
                        FileOutputStream fout=new FileOutputStream(fnewtemp);     
                        int ch;
                        String temp;
                        do
                        {     temp=din.readUTF();
                             ch=Integer.parseInt(temp);
                             if(ch!=-1)
                                  fout.write(ch);                         
                        }while(ch!=-1);
                        fout.close();
                        //dout.writeUTF("written temp en file");
                        // Decrypt
                    encrypter.decrypt(new FileInputStream(fnewtemp),
                    new FileOutputStream(ftemp));
                        //String Option;
                        dout.writeUTF("Delete");                    
                        System.out.println("File Upload Successfull--Duplicate file with timestamp Created");          
                        boolean success1 = fnewtemp.delete();                    
                        return "hello" ;
         void ReceiveFile() throws Exception
              String ip=din.readUTF();
              System.out.println("\tRequest Coming from Internal IP Address : "+ ip);
              String filename=din.readUTF();
              if(filename.compareTo("File not found")==0)
                   return;
              // Destination directory
       File dir11 = new File("C:\\FTPnew");
                        boolean success22 = dir11.mkdir();
                        if (!success22) {
                             // Directory creation failed /Already Exists
                        File dir = new File("C:\\FTPnew\\server");
                        boolean success21 = dir.mkdir();
                        if (!success21) {
                             // Directory creation failed /Already Exists
              File f=new File(dir ,"enc-"+filename);
              File fe=new File(dir,filename);
              String option;
              if(fe.exists())
                   //dout.writeUTF("File Already Exists");
                   String compvalue = Compare(filename);
                   //dout.writeUTF(compvalue);
                   if(compvalue.compareTo("hello")==0)
                        //dout.writeUTF("Transfer Completed");
                        return;
                   option=din.readUTF();
              else
                   //dout.writeUTF("SendFile");
                    option="Y";
                   if(option.compareTo("Y")==0)
                        // Generate a temporary key.       
            // Create encrypter/decrypter class
             DesEncrypter encrypter = new DesEncrypter("My Pass Phrase!");
                 FileOutputStream fout=new FileOutputStream(f);                    
                        int ch;
                        String temp;
                        do
                        {     temp=din.readUTF();
                             ch=Integer.parseInt(temp);
                             if(ch!=-1)
                                  fout.write(ch);                         
                        }while(ch!=-1);
                        fout.close();                    
                        // Decrypt
                    encrypter.decrypt(new FileInputStream(f),
                    new FileOutputStream(fe));          
                        boolean success2 = f.delete();
                        dout.writeUTF("Delete");
                        System.out.println("File Upload Successfull");                    
                   else
                        return;
         public void run()
              while(true)
                   try
                   String Command=din.readUTF();
                   if(Command.compareTo("SEND")==0)
                        System.out.println("\tSEND Command Received ...");     
                        ReceiveFile();
                        continue;
                   catch(Exception ex)
                        //System.out.println("\tClient Terminated Abnormally ...........");
                        continue;

    Please note that this is not an FTP client and server. FTP is defined by a standard IETF protocol and this isn't it.
    Then, move the following lines:
    din=new DataInputStream(ClientSoc.getInputStream());
    dout=new DataOutputStream(ClientSoc.getOutputStream());
    System.out.println("FTP Client Connected ...");
    System.out.println("External IP of Client ..." + ClientSoc.getInetAddress());
    //System.out.println("FTP Client Connected ..."+ClientSoc.getRemoteSocketAddress());from the constructor into the run() method. i.e. don't do anything with the socket in the thread which handles the accept().

  • IOS 4.1 issues: 2nd gen ipod touch: safari and weather

    In general i did not like what the upgrade from 3.1.3 to 4.0 did to my touch. It become soooooo sloooow on mail and had shortened battery life. However to be fair, the wifi range was improved a little and also network speeds. Clicking on settings however caused a blank screen for around 6 seconds (tap tap tap go the fingers...) whereas on 3.1.3 it was <1 second. Could not revert to 3.1.3 as the cert had expired by the time I got around to it (a couple maybe 3 days) so onwards and upwards...hoping that 4.1 might have fixed a few bugs
    (I should know better by now, majornumber.minornumber = upgrade with new bugs, majornumber.minornumber.yetanothernumber = most bugs fixed, like say dos 6.22)
    I took the plunge and upgraded to 4.1
    good news: some bugs are fixed:
    1. it only takes about 3 seconds now (vs 6 before) to open settings
    2. battery life seems a scosche better
    bad news and weirdness:
    1. safari was formerly the king of ipod browsers for me however OS 4.1 introduced a new bug into safari:
    on a site I scan a lot for finance news zerohedge.com/rss.xml it comes up fine as before to the first page via a redirect to reader.mac.com -
    http://reader.mac.com/mobile/v1/http%3A%2F%2Ffeeds.feedburner.com%2Fzerohedge%2F feed
    but when I click on any link in the wonderfully formatted for ipod/iphone RSS feed it now goes to a blank page whereas before it would snap up the RSS synopsis in a blink. Now nothing. On my macbook the feed wroks just fine as it always has of course there it's feeds.feedburner.com/zerohedge/feed without going through reader.mac.com
    Could be co-incidence except it was working right before the upgrade and then not right afterwards. Might be an incompatibility with reader.mac.com just introduced... oh well I will just have to write my own RSS formatter for ipod touch and make it work on any browser so I won't need a broken safari any more. Sad really as Safari had quite the edge before.
    2. *weather app* I live in San Diego, CA and I use the weather app a lot to check what the temperatures for the day and the week are likely to be.
    Right before the os 4.1 update I checked the temperatures for San Diego and it showed expected temps which agreed with the weather channel on the TV right in front of me.
    Now this is weird: right after the update, the temps on the weather app now show 7 F more than on the weather channel!
    I'm used to both the temps on the weather channel and the weather app agreeing to being off by about the same amount for where I live, I just add a few degrees to the high as we live a few miles inland from downtown.
    The only explanation for this new weirdness that I can think of is that 4.1 is somehow using location awareness to give more accurate temps (hah what would be the chance of that?).
    If that is the case then I'd like to be given the option to choose which zip to use.
    OTOH maybe its just an interesting bug....
    I tried deleting and re-adding San Diego, CA but same result, also tried switching off location services, no difference.
    Oh well I'll wait for 4.1.02 <wide-grin>
    So if you know how to fix these things other than me writing my own RSS reader and mentally subtracting temps to correct, let me know!

    several days later.... today the weather app is still broken:
    weather.com says right now 80F for san diego, ca but on the weather app on the
    touch it says 91F that's quite the discrepancy.
    I note that there have been numerous similar problems for folks after updates over the last several years...guess the wethaer app must have a continuuing glitch built into the software. Tried reloading it from 92093 and same result so it isn't a location issue.
    Can't believe I'm the only one with this issue given how many hits I get for similar issues on previous upgrades.
    Right now it is still soooo broken. Thanks for all the attention Apple, so nice to know y'all care. Love the "let's beta test on the live system" upgrade MO. If anyone should have a test suite for everything it should be Apple. Forget support looks like android is the place to go. see ya.

  • Lion, Boot Camp and Windows 7 Issues

    Couple of questions regarding Lion, Boot Camp and Windows 7... I never had issues with Snow Leopard and setting up Windows 7 on my iMac (expcept the dreaded black screen after restart, bu got that fixed)
    Let me start off with my specs and then I will ask my questions:
    iMac 27"
    i7 Quad Core (1st gen)
    16GB Ram
    1TB HDD
    OS X Lion (Fresh Install - Not Upgrade)
    All updates for OS and iLife and other installed software:
    Adobe Creative Suite CS5
    MS Office 2011
    Boot Camp 4.0
    Window 7 Ultimate
    Ok... here are my questions.
    When I fixed my black screen issues after installing a fresh copy of Windows 7 - I had to install MacFUSE and Tuxera NTFS in order to delete the the stock ATI driver so the second rebot on the install of windows 7 would work and boot correctly. After rebotting into my mac side I now always get this message from Tuxera.
    What does this mean? Now in the finder when looking at the computer drives.. It does not show the BOOTCAMP partition...
    However, when I resart i can hold down the ALT key and get this menu:
    I know this might seem strange to ask, but why are the Macintosh HD and the Recovery HD text smoothed and the Windows text not? Being a design I see the difference and it makes me wonder why this is. (It is almost like the BSOD icon apple used forwhen connecting with shared PCs)... Anyways, I can boot into windows when clicking this drive.
    After getting to windows 7 it will not let me run updated. The OS is activated and I have even installed SP1 manually, but it always tells me that the Update service is not running. When in fact it is. I have checked it and it is set to start automatically. I have reset and shutdown my computer more than 10 times... I can't figure out what the issues are.
    Overview:
    Why do I get the Tuxera NTFS error?
    Why can I see the boot camp partion when manually selecting it form startup, but it does not show in OS X
    I can't get Windows to update? Any ideas?
    Thanks for any help you can provide.

    These various utilities like Tuxera are incompatible with Lion. Partly because MacFuse is incompatible. You need to remove them completely.
    As for the Windows partition you might consider using Boot Camp Assistant to remove it. Then make a new partition and install Windows. Remember to use the Windows formatter to format the Windows partition NTFS.

  • Hard Drive Issues (Both new and old)

    I'm trapped in a HDD nightmare with my MacBook Pro mid-2012.
    I updated to Yosemite 10.10.3 (with the Photos app). A couple of days after the update, I was watching a movie on my TV screen via HDMI. In the middle of the movie I removed the HDMI cable from the MacBook Pro and everything freezes. I forced shut down (Note: My HDD was encrypted). After I forced shut down, I tried to turn on and the loading screen would never stop loading - like, 14 hours stuck with the progress bar. Since I have backups, I decided to access DU and format my HDD. I tried everything. For real. Every command line I could type on Terminal to format, repair, erase and/or partition. I read almost every issue-related questions on the forums and stack exchange groups for a week (even posted my issue here: http://apple.stackexchange.com/questions/181090/erasing-and-partitioning-hard-dr ive-from-internet-recovery?noredirect=1#comment215695_181090).
    So, I decided that it was a HDD failure and bought a new one.
    I bought the Seagate 1TB SSHD Hybrid  - ST1000LM014. Installed the new fresh disk and guess what? All those same problems again. I´m not able to restore from Time Machine because it doesn't recognize the disk in the restore page. But the disk is recognized in the DU. When I try to erase or partition the new SSHD, the same old errors: File system formatter failed. Yes, I tired GUID Partition Table, all of the security options, etc.
    Please. Any light that you can throw at this issue, I'll be very grateful for. BTW, the new SSHD is recognized and the SMART Status says: Verified.
    Any ideas on *** is going on?
    Thanks in advance!

    More additional info:
    Booted from my external HDD which contains Time Machine Backups. In Utilities I opened Terminal and typed:
    -bash-3.2# diskutil eraseDisk JHFS+ SSHD_1TB /dev/disk0
    Started erase on disk0
    Unmounting disk
    Creating the partition map
    Waiting for the disks to reappear
    Formatting disk0s2 as Mac OS Extended (Journaled) with name SSHD_1TB
    newfs_hfs: WriteBuffer:  pwrite(3, 0x1071ea000, 1048576, 0): Input/output error
    newfs_hfs: write (sector 0): Invalid argument
    Mounting disk
    Could not mount disk0s2 with name (null) after erase
    Error: -69832: File system formatter failed

  • Hard drive issues after update 10.10.3

    Question also posted here:Hard Drive Issues (Both new and old)
    I'm trapped in a HDD nightmare with my MacBook Pro mid-2012.
    I updated to Yosemite 10.10.3 (with the Photos app). A couple of days after the update, I was watching a movie on my TV screen via HDMI. In the middle of the movie I removed the HDMI cable from the MacBook Pro and everything freezes. I forced shut down (Note: My HDD was encrypted). After I forced shut down, I tried to turn on and the loading screen would never stop loading - like, 14 hours stuck with the progress bar. Since I have backups, I decided to access DU and format my HDD. I tried everything. For real. Every command line I could type on Terminal to format, repair, erase and/or partition. I read almost every issue-related questions on the forums and stack exchange groups for a week (even posted my issue here: http://apple.stackexchange.com/questions/181090/erasing-and-partitioning-hard-dr ive-from-internet-recovery?noredirect=1#comment215695_181090).
    So, I decided that it was a HDD failure and bought a new one.
    I bought the Seagate 1TB SSHD Hybrid  - ST1000LM014. Installed the new fresh disk and guess what? All those same problems again. I´m not able to restore from Time Machine because it doesn't recognize the disk in the restore page. But the disk is recognized in the DU. When I try to erase or partition the new SSHD, the same old errors: File system formatter failed. Yes, I tired GUID Partition Table, all of the security options, etc.
    Please. Any light that you can throw at this issue, I'll be very grateful for. BTW, the new SSHD is recognized and the SMART Status says: Verified.
    Any ideas on *** is going on?
    Thanks in advance!
    MacBook Pro (13-inch Mid 2012), i7, 8GB RAM

    After I erase the hard drive (I assume one pass of writing zeros is good enough, 7 passes not needed?) do I turn off the laptop, then turn on and insert the Install Disk? Will there be a prompt telling me when to put in the disk? Or do I put in the disc right after erasing?
    One pass is fine. If you've previously backed up your hard drive to an external hard drive using SuperDuper!, which is what I use and recommend, or another program, if it created a bootable drive, you want to boot off of it, bring up SuperDuper! and copy the drive back to the internal hard drive. SuperDuper also makes the drive bootable. When done, reboot, and you should be all set. If you're using Time Machine, you'll want to install the operating system, then restore the Time Machine backup. SuperDuper! is available from http://www.shirt-pocket.com/superduper/superduperdescription.html
    Finally- should I update the OS? Is there a problem with the newest update that caused this crash, or was it just a spurious glitch/bad luck?
    I've been running 10.5.8 for awhile with no issues, and would recommend moving to it.

Maybe you are looking for