小编roc*_*now的帖子

如何在java中解析这个日期

请告诉我如何解析这个日期:"2012年7月29日"

我尝试:

new SimpleDateFormat("dd-MMM-yyyy");
Run Code Online (Sandbox Code Playgroud)

但它不起作用.我得到以下异常:

java.text.ParseException: Unparseable date: "29-July-2012"
Run Code Online (Sandbox Code Playgroud)

java parsing date

3
推荐指数
1
解决办法
822
查看次数

TextView ellipsize在RelativeLayout中不起作用

我无法理解为什么我的textview不是椭圆形的.感谢您的任何帮助.
我有这个布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="65dp"
    android:background="@drawable/dash_whiteplate"
    android:minHeight="@dimen/info_activity_list_item_height"
    android:orientation="vertical"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:weightSum="1.0" >

    <RelativeLayout style="@style/ItemFlightRouteLayout" >

        <ImageView
            android:id="@+id/routImageTop"
            style="@style/ItemFlightRouteArrow"
            android:src="@drawable/icon_arrowup_normal" />

        <TextView
            android:id="@+id/routAiroportFrom"
            style="@style/ItemFlightRouteAirportName"
            android:layout_toLeftOf="@+id/topDescription"
            android:layout_toRightOf="@+id/routImageTop"
            android:textAppearance="@style/ItemFlightRouteAirportName"
            android:text="askdjflsfksdfasdfdfsfdsfsdfsfdsdfsfd" />

        <RelativeLayout
            android:id="@+id/topDescription"
            style="@style/ItemFlightRouteDescriptionLayout" >

            <View
                android:id="@+id/verticalDivider"
                style="@style/ItemFlightRouteSeparator"
                android:layout_toLeftOf="@+id/txt_time" />

            <RelativeLayout
                android:id="@+id/txt_time"
                android:layout_width="60dp"
                android:layout_height="match_parent"
                android:layout_toLeftOf="@+id/verticalDivider2" >

                <TextView
                    android:id="@+id/timeDep"
                    style="@style/ItemFlightRouteText"
                    android:textColor="@color/statusLanded" />
            </RelativeLayout>

            <View
                android:id="@+id/verticalDivider2"
                style="@style/ItemFlightRouteSeparator"
                android:layout_toLeftOf="@+id/txt_gate" />

            <RelativeLayout
                android:id="@+id/txt_gate"
                android:layout_width="60dp"
                android:layout_height="match_parent"
                android:layout_alignParentRight="true" >

                <TextView
                    android:id="@+id/desciptionTop"
                    style="@style/ItemFlightRouteText" />
            </RelativeLayout>
        </RelativeLayout>
    </RelativeLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:background="@color/grey" />

    <RelativeLayout style="@style/ItemFlightRouteLayout" …
Run Code Online (Sandbox Code Playgroud)

android textview android-layout

2
推荐指数
1
解决办法
1901
查看次数

分开时输出为零?

也许我看不到明显的事情,但是:

int x1 = 2;
int y1 = 4;
int x2 = 11;
int y2 = 7;
double res = (y2-y1)/(x2-x1);
System.out.println(res);
Run Code Online (Sandbox Code Playgroud)

输出:

0.0
Run Code Online (Sandbox Code Playgroud)

为什么?

java math division

1
推荐指数
1
解决办法
156
查看次数

检查批处理文件中的参数数量

我正在尝试对批处理文件进行简单检查。argCount包含正确的数字,但是比较变量和数字时遇到麻烦。如果参数数量不等于3,我想显示帮助,然后转到文件末尾。
我试过:
if not %argCount% == 3
if not %argCount%=='3'
if not '%argCount%'=='3'
if %argCount% NEQ 3
但是这些选项都没有按预期的方式工作...尝试的大多数选项始终会向我显示帮助消息,而不管参数的数量如何,如果我将3个参数传递给我,则某些选项会向我显示帮助消息而没有前三行脚本(非常奇怪)。

@echo off

set argCount=0
for %%x in (%*) do (
   set /A argCount+=1
)
if not %argCount% == 3 (
    echo This script requires the next parameters:
    echo - absolute path to file
    echo - filter (explanation)
    echo - true or false (explanation)
    echo Examples:
    echo start.bat full\path\to\the\file.ext test true
    echo start.bat full\path\to\the\file.ext nof false
    goto end
)

REM some …
Run Code Online (Sandbox Code Playgroud)

batch-file

1
推荐指数
1
解决办法
5687
查看次数

标签 统计

java ×2

android ×1

android-layout ×1

batch-file ×1

date ×1

division ×1

math ×1

parsing ×1

textview ×1