How to sort a string as integer

Hi,
I need to sort some log files which got timestamps as below:
1149807013000 this is line no 1
1149807023000 this is line no 2
I am converting the date time stamp of the log file to Date.getTime() in a ArrayList and then want to sort this so that i will get them sorted from oldest timestamp to new.
I am using Collections.sort(ArrayList) method, but it is sorting them as String. As this is simple array would it be possible to tell the sort program to sort as Numeric ?. I donot know how to write comparator for this kind of Array, any help here appreciated.
Thanks, Mani

I am posting my method here:
public static void sortLogs(ArrayList al, JTextArea txa){
        Date t;
        SimpleDateFormat formatter;       
        ArrayList al2=new ArrayList();
        for (int i=0;i < al.size();i++) {
            File file=new File(al.get(i).toString());
            if (file.exists()){
                if ( file.getName().startsWith("sys_log")){
                    //Jun 26 12:40:51 2006 BoxMonitor:3:526 enclosure 2 failed to respond to ping at management switch
                    //MMMsDDsTIMEsYR_data
                    try{
                        BufferedReader in=new BufferedReader(new FileReader(file));
                        String line=null;
                        formatter=new SimpleDateFormat("MMM dd HH:mm:ss yyyy",new Locale("en", "US"));
                        while ( (line=in.readLine())!=null){
                            Pattern p=Pattern.compile("^([JFMASOND][aepuco][nbrylgptvc])\\s+([\\d]+)\\s+([\\d]+[:][\\d]+[:][\\d]+)\\s+([\\d]+)\\s+(.*)");// \\s+(.*)");
                            Matcher m=p.matcher(line);
                            if (m.find()){
                                t=formatter.parse(m.group(1)+" "+m.group(2)+" "+m.group(3)+" "+m.group(4));
                                al2.add(t.getTime() + " "+file.getName()+" " + m.group(5));                               
                    }catch(Exception ex){
                        System.err.println("Error on file "+file.getPath()+ " error is "+ ex.getMessage());
        if ( al2.size() > 0) {
            t=new Date();
            formatter=new SimpleDateFormat("MMM dd HH:mm:ss yyyy",new Locale("en", "US"));
            Collections.sort(al2);    //once arraylist al2 is populated with all the files, want to sort which contains String lines like 102020000 filename data
            Pattern p=Pattern.compile("^(\\d+)\\s+(.*)");
            Matcher m;
            for (int j=0;j< al2.size();j++){
                m=p.matcher(al2.get(j).toString());                          
                if ( m.find()) {
                   t.setTime(Long.parseLong(m.group(1)));
                   txa.append(formatter.format(t)+" "+m.group(2)+"\n");                               
    }I am using Collections.sort. As you can see here i am perl guy trying to port my script to java. Was using unix sort on my perl script, but here i am stuck :-).
The ArrayList populated here from reading the text files - finding the date pattern - converting to ephoch seconds, and then i need to sort before converting back to normal date. When i verified the sort output, i see sorting like below:
1
100
2
20
where as in numeric i would like to see,
1
2
20
100
Thanks for your help.

Similar Messages

  • How to compare a string with integer in jsp

    I have a field in database called as enddate
    i m trying to split the entire date and get date,month and year
    once i store the date in a variable called as fmdate which is string,
    i need to compare it with another integer.
    how can i compare it..heres my code
    stdate=RS.getString("start_date");
         fmdate=stdate.substring(8,10);
         fmmonth=stdate.substring(5,7);
         fmyear=stdate.substring(0,4);
    and this is where i want to compare the value of j to fmday...
    <td class="btext" valign="center">Day<select name="fmday">
    <%
    for(int j=1;j<=31;j++)
    String s;
    parseInt(s)=j;
    if (fmdate.equals(s))
    %>
    <option value="<%=j%>"><%=j%></option>
    <% } else { %>
    <option value="<%=j%>"><%=j%></option>
    <%
    } %>
    </select>
    pl help me...
    Thanks Srini

    j is an int, so you're just adding 0, not concatenating. Perhaps something like this would work.
    <%
      for(int j=1;j<=31;j++)
         String date = String.valueOf(j);
         if(j <= 9) {
            date = 0 + date;
         if (fmdate.equals(date)) {
    %>
      <option value="<%=date%>"><%=date%></option>
    <%
         } else {
    %>
      <option value="<%=date%>"><%=date%></option>
    <%
    %>Uhm, I assume there should be a 'selected' or something in one of the option tags?

  • How to get the value of String in integer type

    how to get the value of String in integer

    {color:#0000ff}http://java.sun.com/javase/6/docs/api/java/lang/Integer.html#parseInt(java.lang.String)
    http://java.sun.com/javase/6/docs/api/java/lang/Integer.html#valueOf(java.lang.String){color}

  • How to Sort JTable data using Multiple fields (Date, time and string)

    I have to fill the JTable data with some date, time and string values. for example my table data looks like this:
    "1998/12/14","15:14:38","Unicorn1","row1"
    "1998/12/14","15:14:39","Unicorn2","row2"
    "1998/12/14","15:14:40","Unicorn4","row3"
    "1998/12/17","12:14:12","Unicorn4","row6"
    Now the Sorted Table should be in the following way:
    "1998/12/17","12:14:12","Unicorn4","row6"
    "1998/12/14","15:14:40","Unicorn4","row3"
    "1998/12/14","15:14:39","Unicorn2","row2"
    "1998/12/14","15:14:38","Unicorn1","row1"
    ie First Date field should be sorted, if 2 date fields are same then sort based on time. if date and time fields are same then need to be sorted on String field.
    So if any one worked on this please throw some light on how to proceed. I know how to sort based on single column.
    But now i need to sort on multiple columns.So what is code change in the Comparater class.
    Thanks in advance.. This is urgent....

    I think your Schedule objects should implement Comparable. Then you can sort your linked list using the Collections.sort() method without passing in a Comparator.class Schedule(Date date, String class) implements Comparable
      public void compareTo(Object obj)
        Schedule other = (Schedule)obj;
        return date.getTime() - other.getDate().getTime();
    }

  • How to sort a list of strings, without methods and stuff just simple code?

    Hi
    How to sort a list of strings, without methods and stuff just simple code?
    Thanks in adavance!!

    Without methods? How are you going to all the sort code? What is the point of code?
    Collections.sort(List) will sort strings or anything that implements the Comparable interface, or you can use the sort method that takes a Comparator implemenation.
    If you want "just code", you could either get the Collections class souce and follow it to the code. But otherwise, there isn't one set of code. There are various sorting algorithms with advantages and disadvantages. Maybe you'd be better off searching for sorting algorithms and if you understand them, it should be simple to write Java implementations of them.

  • How can I sort a string

    Hi,
    I want to sort a string (daycode), I use the daycode to sort my data. Now i want to sort the daycodes, but i do not know how.
    Example: the daycode is a10r, so a is the first shift in week (b the second and so on), 10 is the week in year, r is the year.
    Now i have a array with daycode-strings and want to sort it to year, week, shift (normaly it is sorted to the first letter).
    Someone with a good idea???
    Thanks a lot
    Marco

    Try this vi and see if it is something you might be looking for and if not maybe you could explain a little more about what you want to do.
    Joe.
    "NOTHING IS EVER EASY"
    Attachments:
    sort.vi ‏15 KB

  • Convert string to integer

    package onjava;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import org.apache.soap.*;
    import org.apache.soap.rpc.*;
    import java.lang.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class CalcClient extends HttpServlet {
      public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"");
    out.println("\"http://www.w3.org/TR/html4/loose.dtd\">");
    out.println("<html>");
    out.println("<head>");
    out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">");
    out.println("<title>Substraction using SOAP</title>");
    out.println("</head>");
        URL url = new URL ("http://localhost/soap/servlet/rpcrouter");
    Integer p1=request.getParameter("param1");
    Integer p2=request.getParameter("param2");
    In the above statement i have to convert the string to integer because that has to be passed in my program as an argument to a function so please let me know how to do that
        // Build the call.
        Call call = new Call();
        call.setTargetObjectURI("urn:onjavaserver");
        call.setMethodName("subtract");
        call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
        Vector params = new Vector();
        params.addElement(new Parameter("p1", Integer.class, p1, null));
        params.addElement(new Parameter("p2", Integer.class, p2, null));
        call.setParams (params);
        // make the call: note that the action URI is empty because the
        // XML-SOAP rpc router does not need this. This may change in the
        // future.
        Response resp = call.invoke(url, "" );
        // Check the response.
        if ( resp.generatedFault() ) {
          Fault fault = resp.getFault ();
         out.println("The call failed: ");
         out.println("Fault Code   = " + fault.getFaultCode());
         out.println("Fault String = " + fault.getFaultString());
        else {
          Parameter result = resp.getReturnValue();
          out.println(result.getValue());
    out.println("</body>");
    out.println("</html>");

    Two possibilities: Try either java.lang.Integer.valueOf() or java.text.NumberFormat and its parse method.
    Either one will do what you want. I think Integer will be the simpler of the two.
    The code you have is obviously not correct, because getParameter returns a String:
    Integer p1=request.getParameter("param1");Do it like this:
    Integer p1=Integer.valueOf(request.getParameter("param1"));%

  • How to sort files by TimeStamp.

    Hello friends,
    I have files which has following format.
    Paymentxxxx.xml where xxxx is time in YYYYMMDDHH:MM:SS format.Example file name can be
    Payment20010726143455.xml.How to sort such files according to time so that i can get old files first.
    Thanks

    <pre>
    import java.util.*;
    import java.text.*;
    class Timing
         public static void main(String[] args)
              try
              SimpleDateFormat sdf=new SimpleDateFormat();
              String formatter="yyyyMMddhhmmss";
              sdf.applyPattern(formatter);
              //Accept files names here , and deduct extension and pass them into array as following
              String[] inputdates={"19760909132332","19760909032332","19830901132332","19800909132332"};
              Date[] conversionDate=new Date[inputdates.length];
              for(int i=0;i<inputdates.length;i++)
                   conversionDate=sdf.parse(inputdates[i]);
              Date[] outputDates=sortDates(conversionDate);//Sorting dates
              for(int i=0;i<outputDates.length;i++)
              System.out.println(outputDates[i]);//CONVERT DATES INTO STRINGS
              catch(Exception e)
         private static Date[] sortDates(Date[] dates)
              int COUNT = dates.length;
              int j;
              Date tempDate;
              for(int i=0;i<COUNT;i++)
                   j=i-1;
                   tempDate=dates[i];
                   while(j>=0 && tempDate.before(dates[j]))
                        dates[j+1]=dates[j];
                        dates[j]=tempDate;
                        j--;
              return dates;
    </pre>

  • Sorting a String Array in alpha order (Using ArrayList)

    Hello all!
    I am pretty new to Java and am trying to do a, seemingly, simple task; but cannot get the syntax right. I am trying to sort an ArrayList in aplha order based off of the variable String Product. Any help would be awesome!
    First Class:
    //This program stores all of the variables for use in Inventory.java
    public class Vars {
         // defining all variables
         private String product;
         private String prodCode;
         private double price;
         private double invCount;
         // Begin listing getters for class
         public Vars(String product) {
              this.product = product;
         public String getProdCode() {
              return prodCode;
         public String getProduct() {
              return product;
         public double getPrice() {
              return price;
         public double getInvCount() {
              return invCount;
         // Declaring the total variable
         public double total() {
              return invCount * price;
         // Begin listing setters for variables
         public void setProduct(String product) {
              this.product = product;
         public void setProdCode(String prodCode) {
              this.prodCode = prodCode;
         public void setInvCount(double invCount) {
              this.invCount = invCount;
         public void setPrice(double price) {
              this.price = price;
    Second Class:
    //This program will use the variables stored in Vars.java
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Scanner;
    public class Inventory {
         public static void main(String args[]) {
              Scanner input = new Scanner(System.in);
              //defining and declaring local variables
              String exit;
              int counter;
              double gtotal;
              exit = "exit";
              counter = 0;
              gtotal = 0;
              //beginning message and beginning of the loop
              System.out.print("Welcome to the Inventory Contol System\nPlease enter the Product name: ");
              System.out.println();
              System.out.println("When finished entering in the data, please enter EXIT in place of Product name.");
              String name = input.next();
              List<Vars> var = new ArrayList<Vars>(); //creating arraylist object
              //loop while exit is not entered, exit loop once exit is typed into product variable
              while (name.compareToIgnoreCase(exit) != 0) {
                   Vars vars = new Vars(name); //calling Vars methods
                   counter = counter ++;
                   System.out.println("Please enter the Product Code: ");
                   vars.setProdCode(input.next());
                   System.out.println("Inventory Count: ");
                   vars.setInvCount(input.nextDouble());
                   //Making sure that the value entered is a positive one
                   if(vars.getInvCount() < 0){
                        System.out.println("Please enter a positive number: ");
                        vars.setInvCount(input.nextDouble());
                   System.out.println("Price per product:");
                   vars.setPrice(input.nextDouble());
                   //Making sure that the value entered is a positive one
                   if(vars.getPrice() < 0) {
                        System.out.println("Please enter a positive number: ");
                        vars.setPrice(input.nextDouble());
                   System.out.println("Please enter the next Product name, or enter EXIT: ");
                   name = input.next();
                   gtotal += vars.total(); //calculation for Grand Total of all products entered
                   var.add(vars);
                   static void slectionSort(int[] product) {
                   for (int lastPlace = product.length-1; lastPlace > 0; lastPlace--) {
                   int maxLoc = 0;
                   for (int j = 1; j <= lastPlace; j++) {
                   if (product[j] > product[maxLoc]) {
                   maxLoc = j;
                   int temp = product[maxLoc];
                   product[maxLoc] = product[lastPlace];
                   product[lastPlace] = temp;
              //Sorting loop function will go here, before the information is displayed
              //Exit message and array list headers
              System.out.print("Thank you for using the Inventory program.\nHave a wonderful day.\n");
              System.out.printf("Code\tProduct\tCount\tPrice\tTotal\n");
              System.out.println();
              //For loop to display all entries via an ArrayList
              for (Vars vars : var) {
                   System.out.printf("%5s\t%5s\t%.01f\t$%.02f\t$%.02f\n\n", vars.getProdCode(),
                             vars.getProduct(), vars.getInvCount(), vars.getPrice(),vars.total());
              //Displays the amount of entries made and Grand Total of all products entered
              System.out.println();
              System.out.printf("The number of products entered is %d\n", var.size());
              System.out.printf("The Grand Total cost for the products entered is $ %s\n", gtotal);
              System.out.println();
    }

    go through below links, you can easily understand how to sort lists.
    http://www.onjava.com/lpt/a/3286
    http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html
    http://www.javaworld.com/javaworld/jw-12-2002/jw-1227-sort.html

  • How to format paragraph string to show content left, Right or middle of pdf document using iTextsharp ' vb

    Dear All
    how to format paragraph string to show content left, Right or middle of pdf document using iTextsharp in visual basic and absolute position on the document.
    Thanks

     Here is one more example that i have modified the GetCell function so that you can use it for adding all the cells to the document.  It takes several arguments to specify everything you need to create each cell.  It now lets
    you specify the Text, the Text Alignment, the Text Font and color, weather the cell shows the Border, the BackColor of the cell, and the Padding values for the Left, Right, Top, and Bottom.
     If you study the code you should be able to figure out how it works.  From here you can figure out the rest of what you need to do and how to use the
    GetCell function.
     With one quick google search for "iTextSharp Documentation" the first link to pop up was this link.
    iTextSharp Documentation
    Imports System.IO
    Imports Its = iTextSharp.text
    Public Class Form1
    Private dt As New DataTable
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    dt.Dispose()
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    dt.Columns.Add("Name")
    dt.Columns.Add("Age")
    dt.Columns.Add("Birth Date")
    dt.Rows.Add(New Object() {"Johnny", "23", Now.AddYears(-23).ToString})
    dt.Rows.Add(New Object() {"Frank", "41", Now.AddYears(-41).ToString})
    dt.Rows.Add(New Object() {"Rex", "33", Now.AddYears(-33).ToString})
    dt.Rows.Add(New Object() {"Kim", "26", Now.AddYears(-26).ToString})
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim MyPdfFilePath As String = "C:\TestFolder\MyPdf.pdf"
    Dim pSize As New Its.Rectangle(Its.PageSize.A4)
    Dim PdfDoc As Its.Document = New Its.Document(pSize, 10, 10, 10, 10)
    Dim PdfImage As New Its.Jpeg(New Uri("C:\TestFolder\MyLogo.jpg"))
    PdfImage.Alignment = Its.Jpeg.ALIGN_CENTER
    Dim pTable As New Its.pdf.PdfPTable(1)
    pTable.AddCell(getCell("Name : " & TextBox1.Text, Its.pdf.PdfPCell.ALIGN_CENTER, Its.FontFactory.GetFont("Arial", 15, Its.BaseColor.BLACK), False, Its.BaseColor.WHITE, 10, 0, 0, 0))
    pTable.AddCell(getCell("Policy : " & TextBox2.Text, Its.pdf.PdfPCell.ALIGN_CENTER, Its.FontFactory.GetFont("Arial", 20, Its.BaseColor.RED), False, Its.BaseColor.WHITE, 10, 20, 0, 0))
    Dim cTable As New Its.pdf.PdfPTable(dt.Columns.Count)
    For Each col As DataColumn In dt.Columns
    cTable.AddCell(getCell(col.ColumnName, Its.pdf.PdfPCell.ALIGN_CENTER, Its.FontFactory.GetFont("Arial", 12, Its.BaseColor.WHITE), True, Its.BaseColor.BLUE, 3, 5, 0, 0))
    Next
    Dim tblfont As Its.Font = Its.FontFactory.GetFont("Arial", 10, Its.BaseColor.BLACK)
    For Each row As DataRow In dt.Rows
    cTable.AddCell(getCell(row.Field(Of String)("Name"), Its.pdf.PdfPCell.ALIGN_LEFT, tblfont, True, Its.BaseColor.WHITE, 3, 4, 3, 0))
    cTable.AddCell(getCell(row.Field(Of String)("Age"), Its.pdf.PdfPCell.ALIGN_CENTER, tblfont, True, Its.BaseColor.WHITE, 3, 4, 0, 0))
    cTable.AddCell(getCell(row.Field(Of String)("Birth Date"), Its.pdf.PdfPCell.ALIGN_RIGHT, tblfont, True, Its.BaseColor.WHITE, 3, 4, 0, 3))
    Next
    Using fs As New FileStream(MyPdfFilePath, FileMode.Create, FileAccess.Write, FileShare.None)
    Using pdfWrite As Its.pdf.PdfWriter = Its.pdf.PdfWriter.GetInstance(PdfDoc, fs)
    PdfDoc.Open()
    PdfDoc.Add(PdfImage)
    PdfDoc.Add(pTable)
    PdfDoc.Add(cTable)
    PdfDoc.Close()
    End Using
    End Using
    PdfDoc.Dispose()
    End Sub
    ''' <summary>Creates a new cell for the table.</summary>
    ''' <param name="text">The text string for the cell.</param>
    ''' <param name="alignment">Alighnment for the text string.</param>
    ''' <param name="textfont">The font used for the text string.</param>
    ''' <param name="border">True to show the cell border. False to hide the cell border.</param>
    ''' <param name="backcolor">The background color of the cell.</param>
    ''' <param name="padtop">The amount of padding on the top of the text string.</param>
    ''' <param name="padbottom">The amount of padding on the bottom of the text string.</param>
    ''' <param name="padleft">The amount of padding on the left of the text string.</param>
    ''' <param name="padright">The amount of padding on the right of the text string.</param>
    Public Function getCell(ByVal text As String, ByVal alignment As Integer, ByVal textfont As Its.Font, ByVal border As Boolean, ByVal backcolor As Its.BaseColor, ByVal padtop As Single, ByVal padbottom As Single, ByVal padleft As Single, ByVal padright As Single) As Its.pdf.PdfPCell
    Dim cell As New Its.pdf.PdfPCell(New Its.Phrase(text, textfont))
    cell.BackgroundColor = backcolor
    cell.PaddingLeft = padleft
    cell.PaddingRight = padright
    cell.PaddingTop = padtop
    cell.PaddingBottom = padbottom
    cell.HorizontalAlignment = alignment
    If Not border Then cell.Border = Its.pdf.PdfPCell.NO_BORDER
    Return cell
    End Function
    End Class
    If you say it can`t be done then i`ll try it

  • Sort Alphanumeric string in OBIEE answers

    Hi...
    I have a time slot column in my table. I holds data as follows,
    10AM-12PM
    9AM-11AM
    11AM-1PM
    How to sort the report with these column. If i sort it, it was showing data as follows.
    10AM-12PM
    11AM-1PM
    9AM-11AM
    Can u please help to reslove the issue

    If you are specifically trying to use a string function to resolve your issue, then you can try below.
    Pull another slot column in your Answers request and use evaluate function, to derive a timestamp (using oracle to_date funtion) column. Then you can sort this column and hide it in your report.
    Something like below can be used derive timestamp from say '10AM-11AM':
    select to_date(substr('10AM-11AM',1,instr('10AM-11AM','-')-1),'HHAM') from dual --Output 2011-09-01 10:00:00
    Similarly,
    select to_date(substr('10PM-11PM',1,instr('10PM-11PM','-')-1),'HHAM') from dual --Output 2011-09-01 22:00:00
    See if it suits your requirement.
    Thanks

  • Problem in sorting numeric string

    hii
    i have created one method using comparator and passed a list with list of strings as argument to sort method of Collections class.The string ,which is combined a string and numeric value for example A1,A2,A11,A3 .....So i wanted the result as A1,A2,A3..A11,A12... and so on as final output.but when i print the output ,they are sorted as A1,A11,A12....A2,A3....so i learned from javadoc why those are sorted as like since comparator is using charAt() method while making override compare() method.but i am not expected this sorting for my application. i need sorting output as A1,A2,A3...A11,A12.....How to compare a string with another string both have combination of string and number using java?
    if any one know the logic reply me.
    i have pasted my code,if any changes have to be made only in this code,correct the code.
    package sample.sorting;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.List;
    public class SortString {
         public static List<String> sort(List<String> data) {
              Collections.sort(data,new Comparator<String>(){
                   public int compare(String s1,String s2) {
                        return s1.compareTo(s2)     ;
              return data;
         public static void main(String[] args) {
              List<String> sortList     = new ArrayList<String>();
              sortList.add("A1");
              sortList.add("A3");
              sortList.add("A2");
              sortList.add("A9");
              sortList.add("A11");
              sortList.add("A6");
              List<String> sort = sort(sortList);
              for(String str : sort) {
                   System.out.println("STR :: "+str); // O/P : A1,A11,A2,A3,A6... but expected O/P : A1,A2,A3..A11.
    }thanks in advance.
    with regards
    Oasisderts
    Edited by: oasisdesert on Dec 29, 2009 4:15 AM

    In the compare method of the comparator, check if two Strings have equal length, if so compare them as normal, otherwise treat them as a separate case.
    e.g. uncompiled return s1.length == s2.length ? s1.compareTo(s2) : if(s1.length < s2.length) -1 else 1;Mel

  • How to convert a string into orcle date format

    i need some information about converting string into date format.i have string like '20-SEP-05' .so we have to convert into date formate like yy-mm-dd' (2005-09-20).how can we do it.

    Here's some code to help. I can't remember what method uses what format though
      public static java.sql.Date sqlDateValueOf( String dateString ) {
        String stringDate = null;
        if ( dateString == null || dateString.length() < 10 ) return null;
        String strDay = "";
        String strMonth = "";
        String strYear = "";
        if ( dateString.substring(4,5).equals( "-" ) ) {
          strDay = dateString.substring(8, 10);
          if ( strDay.length() < 2 ) strDay = "0" + strDay;
          strMonth = dateString.substring(5, 7);
          strMonth = dateString.valueOf(Integer.parseInt(strMonth) - 1);
          if ( strMonth.length() < 2 ) strMonth = "0" + strMonth;
          strYear = dateString.substring(0, 4);
          stringDate = strDay + "-" + strMonth + "-" + strYear;
        else if ( dateString.substring(2,3).equals( "-" ) ) {
          strDay = dateString.substring(0, 2);
          if ( strDay.length() < 2 ) strDay = "0" + strDay;
          strMonth = dateString.substring(3, 5);
          strMonth = String.valueOf(Integer.parseInt(strMonth) - 1);
          if ( strMonth.length() < 2 ) strMonth = "0" + strMonth;
          strYear = dateString.substring(6, 10);
          stringDate = strDay + "-" + strMonth + "-" + strYear;
        Calendar cal = Calendar.getInstance();
        cal.set( Calendar.YEAR, Integer.parseInt( strYear ) );
        cal.set( Calendar.MONTH, Integer.parseInt( strMonth ) );
        cal.set( Calendar.DAY_OF_MONTH, Integer.parseInt( strDay ) );
        java.sql.Date outDate = new java.sql.Date( cal.getTimeInMillis() );
        return outDate;
      public static String toDateString( java.util.Date date) {
        if ( date == null || date.toString().length() < 10 ) return null;
        String outDate = "";
        SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
        outDate = df.format( date );
        return outDate;
      public static String toDateString( java.sql.Date date) {
        if ( date == null || date.toString().length() < 10 ) return null;
        String outDate = "";
        SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
        outDate = df.format( date );
        return outDate;
      public static String toDateString( java.sql.Date date, String format) {
        if ( date == null || date.toString().length() < 10 ) return null;
        String outDate = "";
        SimpleDateFormat df = new SimpleDateFormat( format );
        outDate = df.format( date );
        return outDate;
      public static String toDateString( java.sql.Timestamp date) {
        if ( date == null || date.toString().length() < 10 ) return null;
        String outDate = "";
        SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
        outDate = df.format( date );
        return outDate;
      }

  • Sorting 2D string array

    Hi I am new to labview. I want to sort my 2D string array by col 1. But I dont know how to sort it perfectly. My sorted array will be something like this.
    Col 1
    A1
    A2
    A3
    A4
    A5
    A6
    A7
    A8
    A9
    A10
    A11

    duplicate, see: http://forums.ni.com/ni/board/message?board.id=170&thread.id=317581&jump=true
    LabVIEW Champion . Do more with less code and in less time .

  • Append String to Integer

    Hi Guys,
    I am trying to append a String to Integer like this;
    String areacode = 020;
    Integer phone_no = 21354214;
    Integer full = areacode && phone_no;My problem is how to join the two datatypes to a single Integer value. Do anyone know how to go about this?
    B

    sabre150 wrote:
    Skotty wrote:
    Without debating the logic of doing such a thing...
    Concatenate them as Strings, then convert that String back to an Integer.Your are on the top floor of the Eiffel Tower and a man is trying to climb over the safety netting but having trouble climbing the netting. You ask him why he is doing this and he says he has to get down to the ground as soon as possible but he has an irrational fear of lifts. Do you help him climb the safety netting or do you advise him that this is not a good idea and try to stop him?I get him to use my camera to take my picture.

Maybe you are looking for

  • API with external system

    Hi, I have to develop API with external system through messages. This is new to me. Could anyone help me how to do this? Thanks, Ashok.

  • Photoshop does not close files and the program does not quit.

    I have been on the phone with tech support for over an hour. Photoshop does not close files and the program does not quit. I am on a Mac and I am using Photoshop CC 2014.

  • Header Column Naming Alias

    My apology first if this question is very basic and pretty simple since I am so new to BI Publisher. It seems that I am unable to create select query that will provide me with result showing the header that I want it on my report. It keeps showing me

  • How do I remove the sound of a door shutting?

    Hi there, I am new to auditions and a complete newbie. I installed the programme because I was told I could remove background noises with it. I have a rather difficult problem. We recorded an interview of a woman, unfortunately, there is a rather lou

  • Transport Management - Tools comparision

    Hi All, We are looking for Advance features for SAP Change management. Particularly in the area of automated transport Sequencing and conflict management between transports. Though CHARM supports sequencing, we need to have automated sequencing. Obje