import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Main {
public static void main(String[] args) {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
System.out.println("Текуще время: " + sdf.format(cal.getTime()) );
DateFormat df = new SimpleDateFormat("Дата: " + "yyyy.dd.MM" + "Время: " + "HH:mm:ss " + "Часовой пояс: X" + "День недели: u" ); //Формируем строку для вывода
Date dateobj = new Date();
System.out.println(df.format(dateobj));
//Текущее время с использованием класса calendar
Calendar calobj = Calendar.getInstance();
System.out.println(df.format(calobj.getTime()));
}
}
Текуще время: 17:40:07
Дата: 2015.05.11Время: 17:40:07 Часовой пояс: +02День недели: 4
Дата: 2015.05.11Время: 17:40:07 Часовой пояс: +02День недели: 4
import java.io.*;
public class Main {
public static void main(String[] args) {
String command = "cmd /c time";
try {
Process process = Runtime.getRuntime().exec(command);
BufferedReader reader = new BufferedReader(new InputStreamReader(
process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
byte[] b = ByteBuffer.allocate(4).putFloat(asFloat).array();
Но на выходе я получаю в обратном порядке [60, -98, 118, -39]
byte[] gf = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putFloat(asFloat).array();
System.out.println("Значение обратно" + Arrays.toString(gf));
И все нормально работает ! private String b = "[3389, 3410, 3430, 3450, 3470, 3500, 3520, 3540, 3760, 3780, 3810, 3830, 3850, 3970, 4000, 4140, 4160, 4180, 4210, 4220, 4250, 4300, 4320, 4340, 4360, 4380, 4400, 4420, 4430, 4440]";
String[] items = b.replaceAll("\\[", "").replaceAll("\\]", "").split(",");
int[] results = new int[items.length];
for (int i = 0; i < items.length; i++) {
try {
results[i] = Integer.parseInt(items[i].trim());
} catch (NumberFormatException nfe) {};
}
Log.d("TEST", Arrays.toString(results));
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="ua.com.ovis.andrey.calibrationforsensors.SensorsCalibrationFirstActivity"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout android:id="@+id/appbar"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:paddingTop="@dimen/appbar_padding_top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways"/>
<android.support.design.widget.TabLayout android:id="@+id/tabs"
android:layout_width="match_parent" android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager android:id="@+id/container"
android:layout_width="match_parent" android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
И все работает как часики )) public class Main {
public static void main(String[] args) {
byte OnOfEngine = -57;
int NumberEngines;
for (NumberEngines = 0; NumberEngines < 8; NumberEngines++) {
if ((OnOfEngine & (1 << NumberEngines)) != 0)
System.out.println("Dvigatel N " + NumberEngines + " vkluchen");
}
}
}
Dvigatel N 0 vkluchen
Dvigatel N 1 vkluchen
Dvigatel N 2 vkluchen
Dvigatel N 6 vkluchen
Dvigatel N 7 vkluchen
Dvigatel N 8 vkluchen
Process finished with exit code 0
public void postData() {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
// nameValuePairs.add(new BasicNameValuePair("параметр", "значение"));
nameValuePairs.add(new BasicNameValuePair("id", "12345"));
nameValuePairs.add(new BasicNameValuePair("stringdata", "Hi"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
new String[]{PASS_ID, PASS_NAME},
null, null, null, null,
PASS_NAME);