Starting httpd in linux

To start httpd, you need to type following commands

<br>
[root@momo ~]# cd /etc/rc.d/init.d/<br>
[root@momo ~]# ./httpd start<br>

To test is httpd service is running, type following command

<br>
[root@momo ~]# ps -ef|grep httpd<br>

and this will give you results like

<br>
apache    2862  2860  0 Aug18 ?        00:00:00 /usr/sbin/httpd<br>
apache    2863  2860  0 Aug18 ?        00:00:00 /usr/sbin/httpd<br>
apache    2864  2860  0 Aug18 ?        00:00:00 /usr/sbin/httpd<br>

To check if your httpd is installed in the system, type below command in the console

<br>
[root@momo ~]# httpd -version<br>

Converting Date to String object

Below is the code for converting Date to specified String. This code uses SimpleDateFormat class for converting Date to String.

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {

public static void main(String[] args) {
DateFormat dateFormat = new SimpleDateFormat("yyyy-dd-mm");
Date now = new Date();

// Convert Date object to date string in the above mentioned format
String strNow = dateFormat.format(now);
System.out.println(strNow);
}
}

Converting String to Date object

Below is the code for converting String of specified format into Date object. This code uses SimpleDateFormat class for converting String to Date.

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {

public static void main(String[] args) {
DateFormat dateFormat = new SimpleDateFormat("yyyy-dd-mm");
String strNow = "2008-11-03";

// Convert given String to date object
try {
Date todayDate = dateFormat.parse(strNow);
System.out.println(todayDate);
} catch (ParseException e) {
e.printStackTrace();
}
}
}

Technology